Open michaellilltokiwa opened 2 months ago
I think finally
or end
could also be confusing, because that sounds as if it is always executed afterwards, but is actually only executed when until
condition is not met. I don't have a better idea though.
@simonvonhackewitz hmm, yes.
I think our use of else
is similar to that in Python, so millions can deal with this, even if Python does not have the counterpart of code following until
. The only alternative I could think of is otherwise
, but that has the same meaning as else
.
fallback
, or else
might also be alternatives. I currently think all of them would be better than having two meanings for keyword else
.
e.g.
for
res list u8 := nil, res ++ byte # contains the decoded data at the end
nxt := 0, nxt + 2
while nxt < data.length
do
bits_0_3 := dec_char_at nxt
bits_4_7 := dec_char_at nxt+1
byte := if bits_0_3.ok && bits_4_7.ok
[(bits_0_3.val << 4) | bits_4_7.val]
else [u8 0] # decoding result not used in error case
until bits_0_3.is_error || bits_4_7.is_error
if bits_0_3.is_error then bits_0_3.err
else bits_4_7.err
else
outcome res.as_array
would be
for
res list u8 := nil, res ++ byte # contains the decoded data at the end
nxt := 0, nxt + 2
while nxt < data.length
do
bits_0_3 := dec_char_at nxt
bits_4_7 := dec_char_at nxt+1
byte := if bits_0_3.ok && bits_4_7.ok
[(bits_0_3.val << 4) | bits_4_7.val]
else [u8 0] # decoding result not used in error case
until bits_0_3.is_error || bits_4_7.is_error
if bits_0_3.is_error then bits_0_3.err
else bits_4_7.err
otherwise
outcome res.as_array
Seems more clear to me with otherwise
Maybe we should use another keyword like
finally
, orend
?At least it confused Simon, Khalil and me in the beginning.