Neat 0.4.1: Breakelse, amended
Some more polish on breakelse
in this one.
expr.else
now creates a breakelse targetable scope inexpr
.
This is because if you have a feature calledbreakelse
, and a
property calledelse
, one better jump to the other.
(I'm a bit worried that I'm giving too much weight here to the
termbreakelse
, which I basically picked out of a hat without
too much thought, but it seems to be working so far.)nullableObject?
no longer returnsnull
. Instead, it willbreakelse
.
Generally,null
is treated equivalently to:else
inbreakelse
features.
This allowsnullableObject?.property.else(...)
and generallynullableObject?
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!