Reputation: 91680
http://julia.readthedocs.org/en/latest/manual/metaprogramming/ discusses macros in Julia, which usually start with @
, but also lists two special macros, text_str
, and cmd
, which handle text"string"
and `shell command`
, respectively. Is there a comprehensive list of these special macros supported by Julia? Is it possible to define your own?
Upvotes: 3
Views: 954
Reputation: 12061
It is indeed possible to make your own; in fact every macro of the form
macro x_str(...)
end
is a String macro. Since 0.6, command macros are also supported by
macro x_cmd(...)
end
Upvotes: 3
Reputation: 11664
So all the macros, including string literal macros, are in exports.jl
.
If you are asking about these special syntax transformations in general like string literal macros, I don't think thats a question thats easily answerable: there are multiple arbitrary syntax translations like that that you can't do in user code (without using an @
to denote you are transforming syntax with a macro). Most Julia macro-or-function-looking things aren't magic, but string literals, ccall
, and maybe even things like A'c
and the like would qualify.
Upvotes: 6
Reputation: 12179
The most sure-to-be-up-to-date way to find out is to enter the folder base
and say grep @ exports.jl
. If you're not on a Unix-like platform, then opening that file and looking at the # Macros
section will also work.
Upvotes: 3