You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The important thing to note here is that the identifier :.+ (== Symbol(".+")) is not the same thing as the standalone expression :(.+) (== Expr(:., :+)). a .+ b parses as Expr(:.+, a, b), but only :(.+) gets lowered to a call to Base.BroadcastFunction, which is why your example doesn't work. I am afraid changing anything about how we parse a .+ b would be too breaking in other places, though, so I don't think there's anything particularly actionable here, except for maybe documenting this potential gotcha a bit better.
A solution in your particular case would be to define something like:
normalize_f(f) = f isa Symbol &&startswith(String(f), ".") ?Expr(:., Symbol(String(f)[2:end])) : f
and using that to normalize the first argument of call expressions.
simeonschaub
changed the title
Macros not working with .* after #37583
infix .* parses differently than standalone .*
Oct 30, 2020
I really appreciate #37583, it will hopefully make metaprogramming easier.
However I don't think the full features of
.*
etc. work properly yet. Here is an MWEI'm not experienced enough with metaprogramming to know exactly at what stage Julia is testing for the existence of
.+
. However note thatAny insights are appreciated!
cc @simeonschaub
The text was updated successfully, but these errors were encountered: