futurescript
futurescript copied to clipboard
Suggestion: better alternatives for ifnull and ifvoid
a ifnull: 8 equivalent to a = a || 8 or a ||= 8 in ruby.
For fus it could be a: self | 8 or perhaps a: ? 8
In general null is known as the billion dollar mistake
For a ifvoid: 8 # if (a === undefined) {a = 8;} could be a: ! 8 ie. must be 8 if not defined.
b: a ifvoid 8 # b = a !== undefined ? a : 8; could then be b: a ! 8 set b to a and must be 8 if a not yet defined
I have a plan of adding some new grammars:
b: a ok.or 8
b: a exist.or 8
equivalent to:
b: a ifnull 8
b: a ifvoid 8
I admit that ifnull and ifvoid may be not very intuitive in some cases.