That code doesn't work properly in parenscript, btw. It does not decrement.
(function () { var collect66 = []; for (var num = 10; num <= 1; num += 1) { collect66['push'](num); }; return collect66; })();
That code doesn't work properly in parenscript, btw. It does not
decrement.
PS's LOOP works just like CL's in this respect, so what Boris meant to say was :DOWNTO rather than :TO. There are four options here. :TO and :DOWNTO are inclusive, while :BELOW and :ABOVE are exclusive:
(loop :for num :from 1 :to 10 :collect num) => (1 2 3 4 5 6 7 8 9 10)
(loop :for num :from 10 :downto 1 :collect num) => (10 9 8 7 6 5 4 3 2 1)
(loop :for num :from 1 :below 10 :collect num) => (1 2 3 4 5 6 7 8 9)
(loop :for num :from 10 :above 1 :collect num) => (10 9 8 7 6 5 4 3 2)
Daniel
On Tue, Jan 15, 2013 at 1:18 PM, David Sargeant david@dsargeant.com wrote:
That code doesn't work properly in parenscript, btw. It does not decrement.
(function () { var collect66 = []; for (var num = 10; num <= 1; num += 1) { collect66['push'](num); }; return collect66; })();
parenscript-devel mailing list parenscript-devel@common-lisp.net http://lists.common-lisp.net/cgi-bin/mailman/listinfo/parenscript-devel
On 16 Jan 2013, at 00:18, David Sargeant wrote:
That code doesn't work properly in parenscript, btw. It does not decrement.
(function () { var collect66 = []; for (var num = 10; num <= 1; num += 1) { collect66['push'](num); }; return collect66; })();
Sorry, my bad. The lower limit should be specified by the keyword :DOWNTO rather than :TO, and it's the same with the Common Lisp LOOP. (I see that Daniel already posted the correct version.)
— B. Smilga.
Also, there is this baddie:
On 16 Jan 2013, at 00:18, David Sargeant wrote:
(function () { var collect66 = []; for (var num = 10; num <= 1; num += 1) { collect66['push'](num);
^^^^^^^^^^^^^^^^^^^^^^^^^^
}; return collect66;
})();
Not at all a major issue, but collect66.push would fit rather better in this context. There are a couple more instances of this kind in the code of ParenScript, they all boil down to keywords being used with @ instead of literal symbols:
src/lib/ps-dom.lisp:6: `(@ ,el :inner-h-t-m-l)) src/lib/ps-dom.lisp:12: `((@ ,el :get-attribute) ,attr)) src/lib/ps-loop.lisp:102: (then (if (numberp by) ` ((@ ,var :slice) ,by) `(,by ,var)))) src/lib/ps-loop.lisp:167: (:collect `((@ ,var :push) ,item)) src/macros.lisp:177: (if (eql ,funobj (@ __PS_MV_REG :tag)) src/macros.lisp:178: (@ __PS_MV_REG :values) src/non-cl.lisp:189: `((@ (list ,@things) :join) "")))
Do you think we should fix them, or is this totally insignificant?
— B. Smilga.
I think it's significant, though admittedly minor, because readable JS is one of the goals of the project.
Speaking of readable JS, by far the biggest problem I encounter is when PS bundles a complex expression into comma-delimited Javascript like "(foo(),bar(),baz())" which is basically a progn that evaluates to baz(). These things often create monstrous one-liners. I don't have a good idea of what to do about it -- I recall that Vladimir tried to pretty-print them at one point and this turned out harder than it seemed -- but it's definitely the #1 thing that would prevent me from trying to persuade a JS programmer that my compiled PS is readable.
On Thu, Jan 17, 2013 at 9:44 AM, Boris Smilga boris.smilga@gmail.comwrote:
Also, there is this baddie:
On 16 Jan 2013, at 00:18, David Sargeant wrote:
(function () {
var collect66 = []; for (var num = 10; num <= 1; num += 1) { collect66['push'](num);
^^^^^^^^^^^^^^^^^^^^^^^^^^
}; return collect66;
})();
Not at all a major issue, but collect66.push would fit rather better in this context. There are a couple more instances of this kind in the code of ParenScript, they all boil down to keywords being used with @ instead of literal symbols:
src/lib/ps-dom.lisp:6: `(@ ,el :inner-h-t-m-l)) src/lib/ps-dom.lisp:12: `((@ ,el :get-attribute) ,attr)) src/lib/ps-loop.lisp:102: (then (if (numberp by) `((@ ,var :slice) ,by) `(,by ,var)))) src/lib/ps-loop.lisp:167: (:collect `((@ ,var :push) ,item)) src/macros.lisp:177: (if (eql ,funobj (@ __PS_MV_REG :tag)) src/macros.lisp:178: (@ __PS_MV_REG :values) src/non-cl.lisp:189: `((@ (list ,@things) :join) "")))
Do you think we should fix them, or is this totally insignificant?
— B. Smilga.
______________________________**_________________ parenscript-devel mailing list parenscript-devel@common-lisp.**net parenscript-devel@common-lisp.net http://lists.common-lisp.net/**cgi-bin/mailman/listinfo/** parenscript-develhttp://lists.common-lisp.net/cgi-bin/mailman/listinfo/parenscript-devel
parenscript-devel@common-lisp.net