On Fri, Aug 15, 2008 at 12:22 AM, Michael Haufe <[EMAIL PROTECTED]> wrote: > I apologize if this issue was discussed already, I've been unable to > find an answer after a few hours of digging and Googling. > > I was watching some old SICP videos and translating some of the code > into JavaScript to see how it compared to Scheme and came across a > couple of errors when implementing Peano Arithmetic.
I think it's a case of mistranslation. When Scheme says (+ x 1), the right ECMAScript translation is x + 1, not x++. So, in your examples: > return add2(x--,y++); //recursion error return add2(x - 1, y + 1); > return add3(x,y)++; //error: cannot assign to a function result return add3(x, y) + 1; Incidentally, ECMAScript does not have Scheme-like tail recursion, so the examples from SICP will not all necessarily work. -j _______________________________________________ Es4-discuss mailing list [email protected] https://mail.mozilla.org/listinfo/es4-discuss
