You ask why the "@" symbol is needed, and then point out that you can have a macro and function of the same name, and that might lead to subtle mistakes. I think you just answered your own question!
Macros are called at parse time, and it's valuable to have a clear syntax to distinguish from run-time behavior. On Tue, Jul 5, 2016 at 5:47 AM, Rangarajan Krishnamoorthy < [email protected]> wrote: > Hi, > I am new to Julia, but have a background in Lisp and other languages. I > found it interesting that Julia supports Macros similar to Lisp. A few > questions: > 1) Julia uses "@" operator as a prefix to a macro call. Why is this needed > at all? Why not call it like a normal function without the prefix? > > 2) Consider this macro: > macro myEval(anexpr) > parse(anexpr) > end > After defining this macro, the expression: > typeof(myEval) > triggers an "undefVarError". Why? The symbol "myEval" is a macro > definition. There must be some type for it? > (If this is a "Function", then type is returned correctly.) > > 3) Julia allows me to define both a function and a macro to have the same > name. Isn't this likely to lead to subtle mistakes? > > Regards, > Rangarajan >
