3 ms·
If it parses to primitive data structures (and actually produces a structure) and allows you to intercept the code between parsing and evaluation/compilation, t
by fiddlerwoaroof 6y ago
If it parses to primitive data structures (and actually produces a structure) and allows you to intercept the code between parsing and evaluation/compilation, this is exactly what I’m saying.
- pjc50 6y agoThis sounds like LINQ would definitely qualify? https://docs.microsoft.com/en-us/dotnet/api/system.linq.expressions?view=netcore-3.1 https://docs.microsoft.com/en-us/dotnet/api/system.linq.expr... I think your best insight here is the importance of the "lid off" intermediate representation; plenty of languages have an eval function of some sort, but it does both READ and EVAL in your terms with no intermediate access to the parsed representation.
- fiddlerwoaroof 6y agoThe issue I’ve had with things like that is that I have to learn a whole new API for manipulating syntax: while there are definite advantages to this, representing code as everyday types that very generic functions can operate on has the advantage of making metaprogramming look like normal code. e.g. if I’m doing try...finally... stuff alot, I can right a macro that transforms: (with-db [conn (connect ...)] ...) To: (let [db (connect ...)] (try ... (finally (close db))) Just like: (defmacro with-db [[sym expr] & body] `(let [~sym ~expr] (try ~@body (finally (close ~sym))))) The backtick/tilde notation isn’t macro-specific: it’s a generic way to template readable datastructures that I can use anywhere, so when I see it in a macro, it isn’t some strange API to learn, it’s just a handy way to build up the datatypes I use all the time.