Skip to content

ISLE should have match expressions #5771

Open
@fitzgen

Description

@fitzgen

If I want to match on something in an RHS, I have to split the continuation out into a new rule:

(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:

(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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    isleRelated to the ISLE domain-specific language

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions