-
-
Notifications
You must be signed in to change notification settings - Fork 79
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Matching interpolation syntax #106
Comments
Maybe you could use |
That would be a nice idea if the purpose was to just work easier with it later, but it bites its own tail, since the But I guess the answer is then that no, such matching can't be done yet with |
I noticed that at least you can match on julia> @eval @capture expr $(Symbol("x_\$"))
true
julia> x
:($(Expr(:$, :sdf))) The problem is that you can't construct a variable called |
You can do this by interpolating a match expression that you build by hand: @capture Expr(:$, :x) $(Expr(:$, :x_)) Unfortunately this doesn't actually give you julia> MacroTools.trymatch(Expr(:$, :x_), Expr(:$, :ex))
Dict{Any,Any} with 1 entry:
:x => :ex |
Interesting. I see that for the interpolation variant of Could |
Unfortunately not: we have to scan the expression at compile time to figure out what should be bound to local variables, but if you interpolate like that then it can vary at run time. |
Is there any way to match on expressions with a
:$
head? Like, replacingby
where
expr
is, for example, defined as follows:I also tried interpolating the
$
itself, but it didn't help:(obviously, since the match expression of this is a
Expr(:call, :$, :e_)
and not an interpolation).The text was updated successfully, but these errors were encountered: