Skip to content
This repository was archived by the owner on Apr 25, 2025. It is now read-only.
This repository was archived by the owner on Apr 25, 2025. It is now read-only.

Could the different try variants be combined? #131

Closed
@tlively

Description

@tlively

Kudos to @ioannad for the great write up in #87!

One thing that stood out to me was the large number of try variants, and I wanted to ask about them in a new issue to avoid cluttering up that other thread. We currently have the following:

instr ::= ... | throw x | rethrow
        | try bt instr* (catch exnidx instr*)+ end
        | try bt instr* (catch exnidx instr*)* catch_all instr* end
        | try bt instr* catch_br l
        | try bt instr* unwind instr* end

It's clear that try-catch_br needs to be its own separate variant, but I wonder if it would be simpler to combine the other variants:

instr ::= ... | throw x | rethrow
        | try bt instr* (catch exnidx instr*)* (catch_all instr*)? (unwind instr*)? end
        | try bt instr* catch_br l

One quirk of this formulation is that it would allow for try bt intr* end, which is completely useless. I imagine it would just have the semantics of a normal block. The other obvious change is that this formulation would allow a try to have both catches and an unwind. I imagine the semantics of that would be similar to the semantics of this:

try
  try
    ...
  catch
    ...
  end
unwind
  ...
end

Specifically, if the catch body rethrows, the unwind body is still run afterwards. So this would just allow for saving a level of try nesting.

I don't feel strongly about this at all since it is just a surface syntax change, but I think it might be a nice simplification. I'm curious to hear what other people think and whether this change would complicate anything I've overlooked.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions