[parenscript-devel] Bug: incorrect JS emitted for binary operators with more than 2 operands
PS generates code for expressions like (> x y z) as if the operators worked the same way in JS and Lisp, but they don't. For example, (ps (> 3 2 1)) => "3 > 2 > 1;" ... is an expression that is true in Lisp but false in JS. Daniel
I ran across this bug a long time ago. The equivalent of (> x y z) in JS would be (x > y) & (y > z). 'y' is evaluated multiple times, so you'd need to introduce a temporary variable for it. I wonder if there is any other approach (other than limiting the comparison operator to two arguments)? Vladimir On Wed, Aug 5, 2009 at 1:45 PM, Daniel Gackle<danielgackle@gmail.com> wrote:
PS generates code for expressions like (> x y z) as if the operators worked the same way in JS and Lisp, but they don't. For example,
(ps (> 3 2 1)) => "3 > 2 > 1;"
... is an expression that is true in Lisp but false in JS.
Daniel
_______________________________________________ parenscript-devel mailing list parenscript-devel@common-lisp.net http://common-lisp.net/cgi-bin/mailman/listinfo/parenscript-devel
Given that the code currently emitted is incorrect, it's not like you have to worry about backward compatibility. Throwing an error would probably suffice. On Thu, Aug 6, 2009 at 7:04 PM, Vladimir Sedach <vsedach@gmail.com> wrote:
I ran across this bug a long time ago. The equivalent of (> x y z) in JS would be (x > y) & (y > z). 'y' is evaluated multiple times, so you'd need to introduce a temporary variable for it. I wonder if there is any other approach (other than limiting the comparison operator to two arguments)?
Vladimir
On Wed, Aug 5, 2009 at 1:45 PM, Daniel Gackle<danielgackle@gmail.com> wrote:
PS generates code for expressions like (> x y z) as if the operators worked the same way in JS and Lisp, but they don't. For example,
(ps (> 3 2 1)) => "3 > 2 > 1;"
... is an expression that is true in Lisp but false in JS.
Daniel
_______________________________________________ parenscript-devel mailing list parenscript-devel@common-lisp.net http://common-lisp.net/cgi-bin/mailman/listinfo/parenscript-devel
_______________________________________________ parenscript-devel mailing list parenscript-devel@common-lisp.net http://common-lisp.net/cgi-bin/mailman/listinfo/parenscript-devel
Ok, I did the temporary variable thing. On Thu, Aug 6, 2009 at 7:12 PM, Daniel Gackle<danielgackle@gmail.com> wrote:
Given that the code currently emitted is incorrect, it's not like you have to worry about backward compatibility. Throwing an error would probably suffice.
On Thu, Aug 6, 2009 at 7:04 PM, Vladimir Sedach <vsedach@gmail.com> wrote:
I ran across this bug a long time ago. The equivalent of (> x y z) in JS would be (x > y) & (y > z). 'y' is evaluated multiple times, so you'd need to introduce a temporary variable for it. I wonder if there is any other approach (other than limiting the comparison operator to two arguments)?
Vladimir
On Wed, Aug 5, 2009 at 1:45 PM, Daniel Gackle<danielgackle@gmail.com> wrote:
PS generates code for expressions like (> x y z) as if the operators worked the same way in JS and Lisp, but they don't. For example,
(ps (> 3 2 1)) => "3 > 2 > 1;"
... is an expression that is true in Lisp but false in JS.
Daniel
_______________________________________________ parenscript-devel mailing list parenscript-devel@common-lisp.net http://common-lisp.net/cgi-bin/mailman/listinfo/parenscript-devel
_______________________________________________ parenscript-devel mailing list parenscript-devel@common-lisp.net http://common-lisp.net/cgi-bin/mailman/listinfo/parenscript-devel
_______________________________________________ parenscript-devel mailing list parenscript-devel@common-lisp.net http://common-lisp.net/cgi-bin/mailman/listinfo/parenscript-devel
participants (2)
-
Daniel Gackle
-
Vladimir Sedach