DreamBerd icon indicating copy to clipboard operation
DreamBerd copied to clipboard

ternary expressions? what operator : very good!

Open jasonflorentino opened this issue 2 years ago • 7 comments

jasonflorentino avatar Dec 01 '22 23:12 jasonflorentino

?

TodePond avatar Dec 02 '22 18:12 TodePond

:

TodePond avatar Dec 06 '22 10:12 TodePond

thinking that since booleans can be true, false or maybe, ternaries can evaluate either the first expression, second expression, or both! or neither. hmm

jasonflorentino avatar Dec 06 '22 13:12 jasonflorentino

Considering ? is taken already for debugging, why not use the tilde?

condition ~? is_true ~; isnt_true ~: is_maybe

Used ; because that's "not" in DreamBerd, but tbh I'm not sure about the ~:, what about just ~~?

Could also do something like this and leave out any of the branches:

condition ~? is_true ~; isnt_true!
condition ~? is_true ~: is_maybe!
condition ~; isnt_true ~: is_maybe!

Magnogen avatar Dec 07 '22 14:12 Magnogen

May I suggest a better, more performant variant,

condition ???
    :: if_true
    ::: if_false
    :::: if_maybe

ksdme avatar Jun 05 '23 04:06 ksdme

That's great. I think DreamBerd definitely needs a quaternary operator

GoldenStack avatar Oct 05 '23 14:10 GoldenStack

If the - sign becomes completely unused (#4), that could be used.

ThePython10110 avatar Jul 05 '24 20:07 ThePython10110