No Way to Rename Macros?

After the significant changes between 0.6.4 and 0.7 and up, I have tasked myself the job of creating version independent code. There are several instances where a simple replacement of one macro name with another would suffice. However this appears to be impossible with Julia as far as I can tell.

An important example is the case where the macro @parallel is essentially replaced with @distributed in v0.7. In my versioning logic I can not simply set parallel = distributed; I get an undefined error. Furthermore it appears I can not simply create a new macro of the form,

macro par(args...)
:( @distributed $(args...) )

It seems that other macros won’t play nice with my renaming, ie

@sync @par ....

does not have the same effect as

@sync @distributed ...

No doubt there are some kind of environment dependencies or escaped variables etc. that are lost in the translation. Is there any way to fix this situation? Can one do a pure textual macro that get’s evaluated and has the same properties as the original macro? The complexity and surprises in the macro system are rather daunting.

Can you do something like:

@static if VERSION < v"0.7-"

at the call site? It’s not terribly pretty, but I think it would work (on mobile now, so I can’t test it).

You can do this:

if VERSION < v"0.7-"
    @eval const $(Symbol("@oldmacro")) = $(Symbol("@newmacro"))


julia> @eval const $(Symbol("@hello")) = $(Symbol("@info"));

julia> @hello "Hello"
[ Info: Hello

Tried that but with relatively complex macros like @sync and @distributed I think you would have to copy the entire for loop twice into each branch of that if statement.

So far what I’ve done is define a @distributed macro for use in Version < v"0.7.0" . In 0.6.4 I don’t seem to be getting the weird side effects from nesting macros in other macros. I did file a bug report, because I think it may actually be a bug in how gensym() creates symbols, but it’s too far down in the weeds for me to figure out.

Uh wow. Not sure why one needs Symbol const or @eval for all this LOL.