3 ms·
I'd like to say I'm a huge fan of Julia, and don't have much experience with metaprogramming in other languages. I'm sure I do more of this than necessary, but
by celrod 7y ago
I'd like to say I'm a huge fan of Julia, and don't have much experience with metaprogramming in other languages.
I'm sure I do more of this than necessary, but much of my code ends up being "generated functions".
@generated foo(x, y)
...
end
When you write an `@generated` function, you write code that creates a Julia expression. Using "x" and "y" in the function give you the types of these arguments. Defining parametric structs lets you pass any information you want (eg, array sizes) to specialize code and algorithms.
A very useful library:
https://github.com/MikeInnes/MacroTools.jl https://github.com/MikeInnes/MacroTools.jl
- FridgeSeal 7y agoMike Innes produces so many cool Julia libraries! Flux is easily the coolest ML framework I’ve used, and I’ve just discovered Lazy.jl.