Our great sponsors
-
WorkOS
The modern identity platform for B2B SaaS. The APIs are flexible and easy-to-use, supporting authentication, user identity, and complex enterprise features like SSO and SCIM provisioning.
Guile supports custom readers through read-hash-extend [1]: this lets you associate specific syntax with a custom reader, triggered by a '#' character. For example, this is how comments are implemented with #! ...multiline comment... !#: the first "#!" triggers a custom reader which reads until the termination.
libfive installs custom readers for #0, #1, #2, and so on, which all do the same thing: store the syntax position (row/column/span), then create a free variable with a particular id that's associated with that syntax position.
When pushing and pulling on the surface, it's solving for free variables values that put the surface at your mouse cursor's position. Then, it can splice those values back into the original script using the row/column/span data from before.
Python does the same thing with a magic `var(...)` function, which is used as the target for an AST transform here:
https://github.com/libfive/libfive/blob/master/libfive/bind/...
[1] http://www.gnu.org/software/guile/manual/guile.html#Reader-E...
I started working on some Rust bindings for this but I'm currently stuck here[0] with some bindgen issue.
If anyone wants to help that would be appreciated heaps.
[0] https://github.com/rust-lang/rust-bindgen/issues/2035
I'd give cxx a shot. I've only written c bindings but I've heard great things about it.
> This library provides a safe mechanism for calling C++ code from Rust and Rust code from C++. It carves out a regime of commonality where Rust and C++ are semantically very similar and guides the programmer to express their language boundary effectively within this regime. CXX fills in the low level stuff so that you get a safe binding, preventing the pitfalls of doing a foreign function interface over unsafe C-style signatures.
https://cxx.rs/
If you're interested in chatting with a random inexperienced student about a month into writing his first Rust bindings I'd enjoy sharing approaches. I'm dzfranklin on the Rust language discord. (If you're not already aware of it #black-magic is great for getting help with unsafe code)