Sorry for linking a local version of the manual -- still, you could probably have found it with a bit of effort, but it appears that you are adamant in your refusal to read it.
I would say that the most important reasons is that macros have special conventions because of hygiene, see http://docs.julialang.org/en/release-0.4/manual/metaprogramming/#hygiene Some languages (eg Common Lisp) have the same namespace for macros and functions, Julia distinguishes them with @. So they are not as seamless as in CL, but at the same time they stand out and warn the reader that source transformation is going on. There could be arguments for both choices, but Julia chose this one. On Sun, Jun 05 2016, Ford O. wrote: > You got it wrong. > In different words. > > Why do we need to specify macro and function block with macro and function > keyword? Isnt the '@' symbol enough? > > On Sunday, June 5, 2016 at 1:11:48 PM UTC+2, Tamas Papp wrote: >> >> A macro is a function that is used to transform (a representation) of >> source code. Consequently, it is called when Julia evaluates your >> function defintions, not at runtime. Please read >> file:///usr/share/doc/julia-doc/html/manual/metaprogramming.html where >> you find examples. >> >> Regarding you example: it is unclear what you are trying to do, but >> unless you use the macro keyword, you get an ordinary function, not a >> macro. >> >> On Sun, Jun 05 2016, Ford O. wrote: >> >> > What makes macro different from function? >> > >> > Why is it not possible to do: >> > foo(e::Expr) = :(&e) >> > @foo x = x + 5 >> > >> > On Friday, June 3, 2016 at 10:05:46 AM UTC+2, Ford O. wrote: >> > >> > I think this deserves an own topic. >> > >> > You should post here syntax that looks like duplicate or you think it >> could use already existing keyword. (mark with # identical or # >> replacement) >> > Rule of thumb - the less special syntax the better. >> > >> > # identical >> > # replace ' , ' with ' ; ' in arrays ? >> > [1, 2, 3, 4] >> > [1; 2; 3; 4] >> > >> > # identical >> > # replace ' = ' with ' in ' in for loops ? >> > for i = 1:10 >> > for i in 1:10 >> > >> > # replacement >> > # replace ' -> ' with ' = ' in anonymous functions ? >> > (a, b, c) -> a + b + c >> > (a, b, c) = a + b + c >> >>
