futurescript icon indicating copy to clipboard operation
futurescript copied to clipboard

Suggestion: better alternatives for ifnull and ifvoid

Open kristianmandrup opened this issue 8 years ago • 1 comments

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

kristianmandrup avatar Mar 06 '17 21:03 kristianmandrup

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.

zhanzhenzhen avatar Mar 07 '17 18:03 zhanzhenzhen