How to appreciate Expr(:meta, args...)

The Julia domment exlaining the Expr type of ‘:meta’ is so concise to a newer like me. What is the manning of Expr(:meta, args…), and how to use it? Simple examples may be helpfull.

1 Like

@nospecialize and @specialize use this to control specialization of parameters. Check @macroexpand @specialize. I believe there are other usages of this meta macro (like in @inline). But basically, the main purpose of Expr(:meta, ...) is to add some new features to Julia’s compiler in a convenient way (by compiler writers). It’s an internal construct, which means that it’s not exposed to normal users. You cannot design arbitrary custom metadata and hope that they will work out of box.
And as you may notice, these features are auxiliary and not an essential part of semantics of the language. So maybe that’s why they don’t have their own syntactic representation, that is, instead of having Expr(:specialize, ...), we have Expr(:meta, :specialize, ...).


Many thanks!