I might be wrong here, but you could imagine "unifying" macros and functions, allowing people to call any function as a macro by prepending a @, or calling any macro as a function by omitting it.
I don't know whether this would be useful, but it's how I read Ford's question. On Sunday, June 5, 2016 at 12:36:30 PM UTC-4, Stefan Karpinski wrote: > > On Sun, Jun 5, 2016 at 11:41 AM, Scott Jones <[email protected] > <javascript:>> wrote: > >> On the other hand, that would prevent having a function with the same >> name as a macro. > > > This is the primary reason. When you define a macro named "@foo", the > transformation function for it is bound to the non-standard symbol "@foo": > > julia> macro foo(x) esc(x) end > @foo (macro with 1 method) > > julia> getfield(Main, Symbol("@foo"))(:(x + y)) > :($(Expr(:escape, :(x + y)))) > > > You can actually define a macro with the function syntax by using eval to > splice in a macro-like name for the function: > > julia> @eval function $(Symbol("@foo"))(x) esc(x) end > @foo (macro with 1 method) > > julia> macroexpand(:(@foo x + y)) > :(x + y) > > > So the syntax for macro definition could be changed to something like this: > > function @foo(x) esc(x) end > > > However this short form: > > @foo(x) = esc(x) > > > would not work since it's ambiguous with having a macro call be the left > hand side of an assignment. >
