PatternDispatch.jl
PatternDispatch.jl copied to clipboard
Add switch statement
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?
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?