> > 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: >
Welcome. You may be interested in this recent talk: https://www.youtube.com/watch?v=dK3zRXhrFZY > 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? > Design decision to let people know that something different is happening. > 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.) > Use: julia> typeof(eval(Symbol("@myEval"))) #@myEval 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? > You can't call them by the same name, see above. In practice this hasn't been a problem (I think most people avoid name duplication as a matter of style, unless there is a good justification to do otherwise). > > Regards, > Rangarajan >
