I am transitioning to Julia from Common Lisp, so I am more accustomed to macros. The use case in the blog post is indeed nice, but these things are routinely done in languages with macros (see, for example, Chapter 7 of Let Over Lambda). The problems you are talking about indeed exist, but they are not fundamentally different from problems of a similar nature in languages without macros (eg how do we ensure that a function is used correctly, etc), and similar solutions apply (well-designed interfaces, basic error checking when applicable, etc).
What I find brilliant is the design choices in Julia that allow smooth operation of macros. I always thought that infix and macros were fundamentally incompatible (historical examples/attempts aside), but the transition from CL has been really smooth for me. I guess that the Lisp family influenced the design choices in Julia fundamentally, even if this is not overemphasized in the manual. Best, Tamas On Sat, Jun 21 2014, Tony Fong <[email protected]> wrote: > Metaprogramming is immensely powerful. I think this use case is brilliant. > > From the short time that I have been experimenting with it for a bit, I'm a > bit torn. I think we should be careful about tradeoff that this technique > forces upon us. > > Starting from a moderately complexity, macros can get difficult to reason > about and edge case problems tends to surface during runtime instead of > compile time with harder-to-read messages. (Sorry, an unscientific > definition of complexity). I found myself having to spend more time in repl > and macroexpand to debug (and to understand others' code). Someone said we > should not use macros when a function would suffice, and I agree. > > Any macros exported by a module should be either so simple that its use is > trivial (e.g. @assert), or that its behavior is thoroughly documented and > tested. But even so how do we communicate incorrect usage of the macro? The > mistake may not even be local to the macro use, but elsewhere. A important > reason why I tried make Lint.jl extensible by module designers is that > macros are almost impossible to lint by default (some of them even > challenges human eye-balls). We need the module designers' help, so that > the ecosystem stays robust. > > Perhaps we should jointly formulate a stronger style guide around > metaprogramming. > > TLDR: metaprogramming (especially together with multiple-dispatch) in julia > is really special. I have a feeling that we haven't really unlocked its > full potential yet, but we need a way to tame the beast. > > On Friday, June 20, 2014 12:31:03 PM UTC-4, Job van der Zwan wrote: >> >> For someone who has hardly ever used meta-programming outside of the >> creation of containers, that was really enlightening! Maybe this is old hat >> to people who work with macros all the time, or compiler writers and other >> people close to the metal, but this is the first time I've seen the concept >> of unrolling *trees**.* Is this a more generalizable technique which can >> also make sense in other data structures? >> >> On Friday, 20 June 2014 15:09:47 UTC+2, Jacob Quinn wrote: >>> >>> Hey all, >>> >>> Thought I needed to jump on the Julia blogging train now that >>> http://www.juliabloggers.com/ is live, so feel free to check out my >>> first post! >>> >>> Blog post: >>> http://quinnj.github.io/2014/06/19/data-structures-as-code-the-joys-of-meta-programming/index.html >>> >>> Hacker News: https://news.ycombinator.com/item?id=7917724 >>> >>> /r/programming: http://www.reddit.com/tb/28kq0n >>> >>> Cheers, >>> >>> -Jacob >>> >>
