Updated copyright notice year in reference manual
[parenscript.git] / TODO.org
bloba27fe27dbeda7ebb2ef343f9cf12ae09135b21ed
1 * Fix BREAKing out of LOOP
2 https://github.com/vsedach/Parenscript/issues/43
4 (ps:ps
5 (defun foo (t1 t5)
6   (loop for t2 in t1
7      for t4 in t5
8      collect (loop for t3 in t2 collect t3))))
10 generates
12 function foo(t1, t5) {
13     __PS_MV_REG = [];
14     return (function () {
15         var _js54 = t1.length;
16         var _js56 = t5.length;
17         var collect57 = [];
18         var FIRST58 = true;
19         for (var _js53 = 0; _js53 < _js54; _js53 += 1) {
20             (function () {
21                 var t2 = t1[_js53];
22                 var _js55 = FIRST58 ? 0 : _js55 + 1;
23                 if (_js55 >= _js56) {
24                     break;
25                 };
26                 var t4 = t5[_js55];
27                 collect57.push((function () {
28                     var _js60 = t2.length;
29                     var collect61 = [];
30                     for (var _js59 = 0; _js59 < _js60; _js59 += 1) {
31                         var t3 = t2[_js59];
32                         collect61.push(t3);
33                     };
34                     __PS_MV_REG = [];
35                     return collect61;
36                 })());
37                 __PS_MV_REG = [];
38                 return FIRST58 = null;
39             })();
40         };
41         __PS_MV_REG = [];
42         return collect57;
43     })();
46 Note that the entire outer-loop body is inside a js function but it still contains break statements.
48 Reverting e6489e0 fixes this issue.
50 This is reduced from a regression in real-world code.
51 @jasom
52 Collaborator Author
53 jasom commented on Jan 11
55 As ECMA script 6 supports block scoping via "let" the only way I see of implementing this would be to wrap the loop in a try and change the break to be a throw. Or we could just not support strict mode and go back to using with (which provides the scoping).
56 @jasom
57 Collaborator Author
58 jasom commented on Jan 11 •
60 Actually for this example "break" could be turned into "return" since the entire loop body is a function.
62 The above doesn't terminate the loop; rather the loop would have to be inside the function and then break could just be used anyways. My comment below is still true.
64 I don't know enough about the loop implementation to say if this works for the general case.
65 @vsedach
66 Owner
67 vsedach commented on Jan 11
68  As ECMA script 6 supports block scoping via "let" the only way I
69  see of implementing this would be to wrap the loop in a try and
70  change the break to be a throw.
71 Correct. I think Parenscript's LOOP is not doing a RETURN-FROM, which
72 would generate a throw in cases like this.
73 @jasom
74 Collaborator Author
75 jasom commented on Jan 17
77 I locally fixd the BREAK to use RETURN-FROM and it gets worse; note that var _js55 = FIRST58 ? 0 : _js55 + 1; is inside the lambda, so js55 is zero on the first iteration and NaN thereafter.
79 Previously only the non-gensymed variables were declared in the with block so the gensym variables took the outer scope; this obviously is not what happens when you replace the with with a lambda. The fix is likely going to involve hoisting those variable declarations out of the loop body; I'm busy with other things currently so it may take several days before I report back.
80 * Fix multiple COLLECT clauses in LOOP
81 https://github.com/vsedach/Parenscript/issues/46
83  phmarek commented 7 hours ago
85 (ps:ps
86     (loop for i from 0 to 3
87           for ch = (char "abcde" i)
88           for p = (char-code ch)
89           collect (logand (ash p -1) 1)
90           collect (logand (ash p -0) 1)))
92 results in
94 (function () {
95     var collect41 = [];
96     var collect41 = [];
97     for (var i = 0; i <= 3; i += 1) {
98         var ch = char('abcde', i);
99         var p = charCode(ch);
100         collect41.push(p >> 1 & 1);
101         collect41.push(p >> 0 & 1);
102     };
103     __PS_MV_REG = [];
104     return collect41;
105 })();
107 Please note the duplicated var collect41 statements.
109 I don't think this breaks JS, but at least it is ugly.
110 * Add DOM3 and DOM4 symbols to PS-DHTML-SYMBOLS
111   https://github.com/vsedach/Parenscript/issues/14
112 * Merge ZEROP, FORMAT from https://github.com/mgi/Parenscript
113 * Add ECMAScript 2015 support
114   https://github.com/pjstirling/Parenscript