Skip to content

Neat 0.4.1: Breakelse, amended

Compare
Choose a tag to compare
@FeepingCreature FeepingCreature released this 11 Oct 07:36
· 180 commits to master since this release

Some more polish on breakelse in this one.

  • expr.else now creates a breakelse targetable scope in expr.
    This is because if you have a feature called breakelse, and a
    property called else, one better jump to the other.
    (I'm a bit worried that I'm giving too much weight here to the
    term breakelse, which I basically picked out of a hat without
    too much thought, but it seems to be working so far.)
  • nullableObject? no longer returns null. Instead, it will breakelse.
    Generally, null is treated equivalently to :else in breakelse features.
    This allows nullableObject?.property.else(...) and generally nullableObject?
    in if statements.

There's a bit of an ugly detail here: .else must be called on a sumtype with
:else or nullptr_t (like nullable Object). So you end up with an expression
containing a chain of ?, and a final .else that ... also does
the thing that ? does. foo?.bar.else(...).

That is, what you may expect, foo?.bar?.else(...), won't actually work,
because bar? already got rid of the null. The reason for this is that it
is not entirely trivial from a compiler perspective to check if the else
branch actually ever gets taken. So allowing .else to be called on arbitrary
expressions would lead to code with .else properties that are not actually
needed (anymore).

This is one of the implementation details of this design that I'll very
likely revisit later.

edit: You know what? That's stupid and broken, I'll definitely revisit it. Look out for 0.4.2!