asmeurer
asmeurer

Reputation: 91680

Is there a comprehensive list of special macros in Julia?

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

Answers (3)

Fengyang Wang
Fengyang Wang

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

IainDunning
IainDunning

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

tholy
tholy

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

Related Questions