bytecodealliance / bytecodealliance/wasmtime
ISLE should have `match` expressions
- Dominant language
- Rust
- Stars
- 18.6k
- Forks
- 1.8k
- Avg merge
- 1d 18h
- Merged PRs (30d)
- 126
Description
If I want to match on something in an RHS, I have to split the continuation out into a new rule:
```wat
(type A extern (enum))
(type B extern (enum I J K))
(type C extern (enum))
(decl a_to_b (A) B)
(extern constructor a_to_b my_a_to_b_impl)
(decl foo (A) C)
(rule (foo a)
(foo2 (a_to_b a)))
(decl foo2 (B) C)
(rule (foo2 (B.I)) ...)
(rule (foo2 (B.J)) ...)
(rule (foo2 (B.K)) ...)
```
I wish that I didn't need to define a new term, and could instead match on `(a_to_b a)` directly inside `foo`:
```wat
(rule (foo a)
(match (a_to_b a)
((B.I) ...)
((B.J) ...)
((B.K) ...)))
```
Some things to think about: partiality and side effects.
But since we can already write this today, just with two terms instead of one, I don't think we should have any show stoppers here.
Contributor guide
Assessment
This issue has not been assessed yet.