[suave-devel] js-to-paren for loop bug
Lui Fungsin
fungsin.lui at gmail.com
Fri Feb 15 19:31:02 UTC 2008
It looks like that the current transformation will reinitialize the
initializers on every iteration.
You can try it with this test case:
(js-on-cl::js-to-paren "for(var i = 0, len = cols.length; i < len;
i++){ c = cols[i];}")
Below is a simple patch for that.
@@ -143,11 +143,10 @@
(condition (for-condition js-form))
(step (for-step js-form))
(body (for-body js-form)) )
- `(while t
+ `(progn
,(as-paren initializer)
- (if (not ,(as-paren condition))
- (break))
- ,(as-paren step) ,(as-paren body))))
+ (while ,(as-paren condition)
+ ,(as-paren body) ,(as-paren step)))))
Also, I notice that the operator ++ is not recognized by parenscript
and it becomes a invalid function call Plus(...)
(ps*
'(PROGN
(PROGN (DEFVAR I 0) (DEFVAR LEN (SLOT-VALUE COLS "length")))
(WHILE (< I LEN) (++ I) (PROGN (= C (SLOT-VALUE COLS I))))))
=>
var i = 0 ;
var len = cols['length'];
while (i < len) {
Plus(i);
c == cols[i];
};
I'm not sure if we should fix js-to-paren to translate ++ to incf or
patch parenscript to recognize ++.
Thanks
More information about the Suave-devel
mailing list