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

Add switch statement #3

Open
toivoh opened this issue Dec 25, 2012 · 1 comment
Open

Add switch statement #3

toivoh opened this issue Dec 25, 2012 · 1 comment

Comments

@toivoh
Copy link
Owner

toivoh commented Dec 25, 2012

Possible syntax:

@match expression begin
    (x::Int)->print(x)
    1->print("one")
    x->print("Not an Int")
end

This should probably create a decision tree directly, without using cooperative dispatch?

@toivoh
Copy link
Owner Author

toivoh commented Dec 25, 2012

Need to figure out the steps to compile this sort of thing.
With @pattern function, we can generate code with the method definition to evaluate the pattern and body function,
then create dispatch code using eval. That is possible since @pattern is invoked at the point of definition, not use.

Is it possible to create dispatch code that knows about the local context, without recompiling at each invocation?
Pattern evaluation is currently mostly used to translate symbols to types in type assertions. Could we create a staged method for the switch dispatch based on what they evaluate to?

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

No branches or pull requests

1 participant