You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ISLE terms should just be functions, from any number of arguments to any number of results. Internal terms should all be defined using rule. Terms with exactly one argument can be used in pattern matches like extractors are today; all terms can be used on the right-hand side of a rule or if-let, like constructors are today. Possibly a form of type-directed overloading should be added to the language to allow the current pattern of using the same term name for both constructor and extractor.
Benefit
Simplify the trie-again and serialized representations of ISLE rules. The current distinction between constructor and extractor makes no difference to code generation.
Using rule to define "extractors" allows a form of "or-patterns" (ISLE: Support commutative matches #6128), without requiring us to figure out how priorities should interact when these patterns are inlined as internal extractors are today.
Implementation
I'd start by unifying constructors and extractors in the trie-again representation and ensuring that the generated code doesn't change.
Then maybe introduce something like (overload iadd extract_iadd construct_iadd) to declare that when the term iadd is used, whichever of extract_iadd or construct_iadd has the right type for that context should be used instead. I'm less sure about this.
Next, extend constructor terms to allow multiple results. A pattern binding the result of such a term needs some extra syntactic care to handle tuples. Semantically, though, we can approximate this today by wrapping up multiple results in an enum with a single variant, so I think we should just make the language support it directly.
Finally, remove the restriction that patterns can only use extractors and expressions can only use constructors, and replace (extractor ...) with (rule ...). Optionally, we could add an inline flag on terms and use it for all current extractors to ensure we still generate the same code, since internal extractors are currently inlined automatically. It is difficult to define inlining for all current combinations of ISLE features, though.
Alternatives
There are so many alternatives. Let's talk about it…
Feature
ISLE terms should just be functions, from any number of arguments to any number of results. Internal terms should all be defined using
rule. Terms with exactly one argument can be used in pattern matches like extractors are today; all terms can be used on the right-hand side of a rule or if-let, like constructors are today. Possibly a form of type-directed overloading should be added to the language to allow the current pattern of using the same term name for both constructor and extractor.Benefit
ruleto define "extractors" allows a form of "or-patterns" (ISLE: Support commutative matches #6128), without requiring us to figure out how priorities should interact when these patterns are inlined as internal extractors are today.Implementation
I'd start by unifying constructors and extractors in the trie-again representation and ensuring that the generated code doesn't change.
Then maybe introduce something like
(overload iadd extract_iadd construct_iadd)to declare that when the termiaddis used, whichever ofextract_iaddorconstruct_iaddhas the right type for that context should be used instead. I'm less sure about this.Next, extend constructor terms to allow multiple results. A pattern binding the result of such a term needs some extra syntactic care to handle tuples. Semantically, though, we can approximate this today by wrapping up multiple results in an enum with a single variant, so I think we should just make the language support it directly.
Finally, remove the restriction that patterns can only use extractors and expressions can only use constructors, and replace
(extractor ...)with(rule ...). Optionally, we could add aninlineflag on terms and use it for all current extractors to ensure we still generate the same code, since internal extractors are currently inlined automatically. It is difficult to define inlining for all current combinations of ISLE features, though.Alternatives
There are so many alternatives. Let's talk about it…