thautwarm / MLStyle.jl

Julia functional programming infrastructures and metaprogramming facilities
https://thautwarm.github.io/MLStyle.jl/latest/
MIT License
404 stars 39 forks source link

Expr pattern is not working with Float #73

Closed Roger-luo closed 5 years ago

Roger-luo commented 5 years ago

MWE:

function foo(ex)
    @match ex begin
        Expr(:call, sin, 2π) => 0
        _ => "unknown"
    end
end

it seems there is no way to eval numerics in the pattern?

Roger-luo commented 5 years ago

should be &2π, this part is a bit intuitive to me. I'm wondering if it is possible to just write without making ambiguity?

thautwarm commented 5 years ago

It's &(2π).

I'm wondering if it is possible to just write 2π without making ambiguity?

It's impossible, I remember we used to discuss about this.

Expr(:call, 2, :π) shouldn't match Expr(:call, 2, π), does it make sense?

Roger-luo commented 5 years ago

yeah, closed.