archives

Branching constructs in intermediate languages

I'm reading Bolingbroke and Peyton Jones' excellent paper Types Are Calling Conventions, and following along by building a quick-and-dirty interpreter for their proposed intermediate language.

There are a couple of options for how to structure the branching construct in such an intermediate language, and I'm curious if anyone has explored the advantages and disadvantages. Bolingbroke and Peyton Jones' have a case expression (branching on values only, since the whole language is in ANF and the idea is to make strictness/laziness explicit) and a very simple pattern language (a wildcard, literals, and unwrapping a single layer of data constructor binding it's arguments), along with an operational semantics that (if I'm reading it correctly) requires evaluating the list of alternatives in order.

Is this easier to work with than an if/then/else expression? Is it to be preferred simply because it doesn't require distinguishing a Boolean type in the intermediate language?

It's clearly equivalent and easy to understand either way, but I'm wondering if one or the other makes it easier to express common optimizations/transformations. Are there other sensible options besides these two?