By the way, David's request led me to experiment with different looping constructs in PS, and in the process I noticed that the behaviour of DOLIST diverges from its Common Lisp prototype when used with a RESULT-FORM that references the iteration variable. E. g.:

  (dolist (i '(1 2 3) (foo i)) (foo i))

expands to

  (function () {
for (var i = null, _js_arrvar58 = [1, 2, 3], _js_idx57 = 0; _js_idx57 < _js_arrvar58.length; _js_idx57 += 1) {
          i = _js_arrvar58[_js_idx57];
          foo(i);
      };
      return foo(i);
  })();

Since JavaScript variables have at least function scope, this effectively evaluates to foo(3), excluding side effects.

On the other hand, CLHS entry for DOLIST (§6.2) contains the following clause:

  dolist (var list-form [result-form]) declaration* {tag | statement}*
  ...

  At the time RESULT-FORM is processed, VAR is bound to NIL.

Given this project's goal, stated by Vladimir in a recent message, of bringing PS semantically as close as possible to Lisp, this discrepancy is rather unfortunate, so please find attached a patch to remove it.

 — B. Smilga.

Attachment: 0001-Set-iteration-var-to-null-when-evaluating-result-of-dolist.patch
Description: Binary data

_______________________________________________
parenscript-devel mailing list
[email protected]
http://lists.common-lisp.net/cgi-bin/mailman/listinfo/parenscript-devel

Reply via email to