Hey guys, now that RapydScript uses strict equality (=== vs ==) I find myself needing to check both null and undefined more and more and this is a problem for two reasons:
- it's a PITA even for devs who're aware of this and makes it easier to write buggy code
- devs unfamiliar with JS are likely to just do a check against None (null) and call it a day
CoffeeScript already handles this via a? operator, I don't want to introduce extra operators that reduce the readability of code, so that's out.
Basically, my proposed solution boils down to either adding exists() function that gets converted to the following at compile time:
typeof a !== "undefined" && a !== null
Or converting "is not None" check to that instead. The drawback for the first solution is that Python code may need a bit more massaging to work in JS, the drawback of the second is that sometimes one may want to compare against null (None) but not undefined, although I can technically allow them to do that via '!= None', which wouldn't kick in the conversion.
If you've written significant amount of RapydScript to form an opinion, I'd love to hear you feedback, either here or in the issue itself.