Skip to content
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

Expr pattern is not working with Float #73

Closed
Roger-luo opened this issue Sep 26, 2019 · 3 comments
Closed

Expr pattern is not working with Float #73

Roger-luo opened this issue Sep 26, 2019 · 3 comments

Comments

@Roger-luo
Copy link
Collaborator

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
Copy link
Collaborator Author

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
Copy link
Owner

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?

  • is a pattern to match a symbol ,
  • π is a pattern to capture the positional value as variable π,
  • is a pattern to match the positional value with the variable π in current scope.

@Roger-luo
Copy link
Collaborator Author

yeah, closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants