Yes, Julia doesn't do reader macros or textual preprocessing, so there's no way to do this (shorting of preprocessing yourself).
On Mon, Jul 7, 2014 at 2:10 PM, Ivar Nesje <[email protected]> wrote: > Julia macros does not work on text, but on the parsed AST. If the modified > syntax parses to something legally, you could do the transformation on the > AST, but you should have a really good reason for wanting to do that. The > syntax (for the user of your macro) would look something like: > > @modify_julia_syntax begin > # code that should be modified > > end > > You can already use some ugly (slow performance) tricks from thenewphalls > <http://thenewphalls.wordpress.com/2014/02/19/understanding-object-oriented-programming-in-julia-part-1/>, > but then you are not getting any benefit from using Julia and should really > consider using Python instead. > > Ivar > > > kl. 19:02:56 UTC+2 mandag 7. juli 2014 skrev christian keppenne følgende: > >> Let's say I wanted to define an alternative syntax for some constructs >> like, for example, >> "debut; ... ; fin" as an alternative syntax for "begin; ... ; end" blocks >> or "<-" as an alternative form for the assignment "=". The first one >> would be easy to do with CPP and the second one with a tool like perl or >> sed. Could such substitutions also be done with a Julia macro that would >> act on the content of an entire file so that the code containing the >> alternative syntax would first be parsed and each occurence of "<-" would >> be replaced with an "=" and "debut; ... ; fin" blocks woulld be replaced >> with "begin; ... ; end" blocks? >> >> Another related question is could a Julia macro be written to mimic >> object oriented call syntax so that one could write. "a->f(b)" or "a.f(b)" >> as an alternative for "f(a, b) "? >> I apologize in advance for the triviality of my question. I have less >> than a week of Julia experience. >> >> >>
