BruceSherwood/glowscript

False == 0 fails

Closed this issue · 3 comments

Here's a issue affecting the innermost workings. Consider the following seemingly-innocent program:

a = 3==4
print("yyyyy", a, 0, a==0)

*) Desired and expected output:
yyyyy False 0 True

This works as expected under visual python from the command line.
The corresponding javascript also works as expected. However...

*) Observed glowscript behavior:
yyyyy false 0 false

This is 100% reproducible chez moi.

This is more important than it might seem. The example above is highly simplified, to facilitate debugging. The same issue affects more-complicated code in ways that are much harder to understand. This wastes significant amounts of programmer time.

For a tiny bit of further information, see next issue.

Thanks for the clear test case. See later comments about RapydScript.

I pushed this upstream to kovidgoyal/rapydscript-ng#38

Note that the linkage to #61 is probably misleading, because this is a compiler issue whereas #61 appears to be an operator-overloading issue, not a compiler issue.

Correct. I used the term "compile" as a shorhand, as the full GlowScript compilation process includes four processes: 1) A lot of preprocessing to implement ascpects of the VPython API where different from the underlying JavaScript engine. 2) In the case of VPython source, invoking the RapydScript transpiler. 3) Handling operator overloading. 4) Invoking Streamline to permit synchronous loops. The intended change from rapydscript to rapydscript-ng will require new versions of all but step 1, because the new RapydScript outputs ES6, not old JavaScript. Fortunately, there do exist ES6 versions for steps 3 and 4, but there's work to be done to put it all together.