JuliaServices / Match.jl

Advanced Pattern Matching for Julia
https://juliaservices.github.io/Match.jl/latest/
Other
240 stars 22 forks source link

Support `T[x,y,z]` patterns for arrays #94

Open nystrom opened 1 year ago

nystrom commented 1 year ago

This is supported:

xs = [1,2,3]
@match xs begin
    [x,y,z] => ...
    ...
end

but not this:

xs = [1,2,3]
@match xs begin
    Int[x,y,z] => ...
    ...
end
gafter commented 1 year ago

@nystrom Is this just an idea, or do you have a use case where this would be helpful to you?

nystrom commented 5 months ago

Not really a use case, but I want to avoid bare arrays in my code since they lead to problems with type inference. This is not a problem in patterns, but would make the pattern syntax match the expression syntax.