Closed Peekmo closed 8 years ago
also == can be is
and != isnt
like in livescript
Yeah, that would be nice addition
+1! moreover, allow non-null values to be considered true. for example if (obj) do... if obj isn't null, then do is executed. this is also from the cobra language. it's quite useful. I'm not sure, but I think they also support 0 as false, in the if statement.
I think it's objective-c that has yes and no, aliased to true and false. sometimes it reads really nice this way. (maybe also: on and off)
This will be added to next version :) According to @kobi2187 suggestion, I am not sure if this will be possible, because in statoc languages you cannot check Int and Bool for null, and I have no way to check it.
Fixed with commit add518a536bc0d9f90efa08dead95223ab2fca0f
by the way good progress with all the requests! thanks!
to clarify, my suggestion was:
[ false, 0, null ]
are false
in if statements.
The down side is that this breaks some of the static typing (if only accepts bool), which may be a little confusing at first, but it looks simple and works well in practice.
it improves clarity, but reduces only little code.
the idea is that every if expression is checked:
# basic code idea
switch (typeof(ifexpr))
case Bool:
return ifexpr
case Int: # or uint
return ifexpr != 0
default:
if ifexpr not inherits Object
assert (false, "add match for ifexpr here")
else
return ifexpr isnt null
It will be nice if
&&
and||
should be replace byand
andor
keywords