4 ms·
Lisp user here. Is bf" like a reader macro?
by fmakunbound 7y ago
Lisp user here. Is bf" like a reader macro?
- eigenspace 7y agoYes, it's a string macro which is essentially a reader macro. We also have regular macros that operate on Julia's AST. There's some really useful and approachable info here: https://docs.julialang.org/en/v1/manual/metaprogramming/index.html https://docs.julialang.org/en/v1/manual/metaprogramming/inde... You can think of Julia as a Lisp-1 with opt out hygenic macros hiding behind Algol syntax. However, the AST is very lispy: julia> dump(:(x^2 - 1)) Expr head: Symbol call args: Array{Any}((3,)) 1: Symbol - 2: Expr head: Symbol call args: Array{Any}((3,)) 1: Symbol ^ 2: Symbol x 3: Int64 2 3: Int64 1 The `:` is how you quote code in Julia, and `dump` is just a convenient function for printing nested data-structures. Furthermore, you can see this package https://github.com/swadey/LispSyntax.jl https://github.com/swadey/LispSyntax.jl for a string macro that lets julia use Lisp style syntax instead.
- fmakunbound 7y agoThanks for the explanation. I'm checking it out.