JuliaLang/julia — pull request #8779 by maleadt (2014-10-23 07:43:06+00:00)
Title: Extend :meta to allow saving extra information.

I wanted to use the recently added `:meta` infrastructure by @timholy to attach some more complex information to function definitions, but it turned out that currently only symbols can be pushed in the metadata expression. This PR extends the `pushmeta!`/`popmeta!` function pair to allow saving whole expressions rather than only symbols, but also allows the old behaviour where just a symbol is pushed.

This can be used in a variety of situations. For example, defining a macro `@unroll 5 ex...`, the function body would look like:
```
$(Expr(:lambda, {}, {{},{},{}}, :(begin
$(Expr(:meta, :($(Expr(:unroll, 5)))))
ex...
end)))
```

To read this metadata, `popmeta!` has been modified to return a tuple `(Bool, Array{Any})` where the `Bool` indicates whether the metadata has been found, and the `Array` matches the `args` of the found metadata expression (or just the empty array `[]` when the metadata is a simple symbol like the one produced by `@inline`).