Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I found it's really cool how you can prefix any variable with # and makes it interactivee. How do you map variables to draggable surface in studio?


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...




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: