Matching interpolation syntax
- Dominant language
- Julia
- Stars
- 320
- Forks
- 84
- PR merge metrics
- No merged PRs in 30d
Description
Is there any way to match on expressions with a `:$` head? Like, replacing
```
if isexpr(expr, :$)
@assert length(expr.args) == 1
:(shift($(esc(expr.args[1]))))
end
```
by
```
@match expr begin
($(e)) => :(shift($(esc(e))))
end
```
where `expr` is, for example, defined as follows:
```
julia> expr = :(:($(sdf))).args[1]
:($(Expr(:$, :sdf)))
julia> dump(expr)
Expr
head: Symbol $
args: Array{Any}((1,))
1: Symbol sdf
```
I also tried interpolating the `$` itself, but it didn't help:
```
julia> @match expr begin
($:$(e_)) => :(shift($(esc(e))))
end
```
(obviously, since the match expression of this is a `Expr(:call, :$, :e_)` and not an interpolation).
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the @match implementation and its handling of interpolation patterns. Reproduce the shown Expr(:$, :sdf) example and compare it with the proposed matching syntax and the attempted interpolated-$ form. Done means establishing whether this expression shape can be matched and implementing or documenting the supported behavior with coverage for the examples.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- julia
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100