[–] suzuki 10y ago ↗ The Lisp in 1,200 lines of Dart, which has macros, quasi-quotation and tail-call optimization (https://news.ycombinator.com/item?id=9903332), was translated into 1,390 lines of TypeScript. It runs on browsers.
[–] lomnakkus 10y ago ↗ Thus, yet again, sort-of-validating Greenspun's 10th Rule.I'm not complaining... just observing :). [–] gadtfly 10y ago ↗ As much as I love a good Greenspun invocation, I don't think this really counts:> Any sufficiently complicated C or Fortran program contains an ad hoc, informally-specified, bug-ridden, slow implementation of half of Common Lisp.isn't about the inevitability of literally implementing a Lisp interpreter.It's about something more abstract. see: http://c2.com/cgi-bin/wiki?LevelsOfGreenspunning [–] lomnakkus 10y ago ↗ Mostly agreed. Which is why I said "sort-of-validating".... so that I would be technically correct. Which, as we all know, is the best kind of correct. (Source: Futurama) [–] DonHopkins 10y ago ↗ It's still got a good shot at validating Zawinski's Law of Software Envelopment.> Every program attempts to expand until it can read mail. Those programs which cannot so expand are replaced by ones which can.
[–] gadtfly 10y ago ↗ As much as I love a good Greenspun invocation, I don't think this really counts:> Any sufficiently complicated C or Fortran program contains an ad hoc, informally-specified, bug-ridden, slow implementation of half of Common Lisp.isn't about the inevitability of literally implementing a Lisp interpreter.It's about something more abstract. see: http://c2.com/cgi-bin/wiki?LevelsOfGreenspunning [–] lomnakkus 10y ago ↗ Mostly agreed. Which is why I said "sort-of-validating".... so that I would be technically correct. Which, as we all know, is the best kind of correct. (Source: Futurama) [–] DonHopkins 10y ago ↗ It's still got a good shot at validating Zawinski's Law of Software Envelopment.> Every program attempts to expand until it can read mail. Those programs which cannot so expand are replaced by ones which can.
[–] lomnakkus 10y ago ↗ Mostly agreed. Which is why I said "sort-of-validating".... so that I would be technically correct. Which, as we all know, is the best kind of correct. (Source: Futurama)
[–] DonHopkins 10y ago ↗ It's still got a good shot at validating Zawinski's Law of Software Envelopment.> Every program attempts to expand until it can read mail. Those programs which cannot so expand are replaced by ones which can.
[–] eatonphil 10y ago ↗ Why does the foldl function use a while loop? [–] xyzzy123 10y ago ↗ I think it's just manual tail-call optimization? [–] junke 10y ago ↗ Why not? map, fold/reduce are not necessarily implemented as the textbook says. [–] suzuki 10y ago ↗ Certainly not. The foldl is a part of the TypeScript program that implements the Lisp.By the way, as for "while" in the implemented Lisp, it is defined with recursion and will be executed with tail-call optimization. See (defmacro while (test &rest body) (let ((loop (gensym))) `(letrec ((,loop (lambda () (cond (,test ,@body (,loop)))))) (,loop)))) in the const prelude of lisp.ts (http://www.oki-osk.jp/esc/typescript/lisp/lisp.ts.html). [–] junke 10y ago ↗ Thanks for this information.My point was more that map and reduce do not inherently require a recursive implementation and can be implemented directly as loops.I don't follow closely TypeScript: is tail-call merging done when compiling to Javascript or is the Javascript runtime responsible for this behavior? [–] suzuki 10y ago ↗ No, neither. That behavior is implemented in the same way as in the Lisp in Dart (http://www.oki-osk.jp/esc/dart/lisp-en.html#4).
[–] junke 10y ago ↗ Why not? map, fold/reduce are not necessarily implemented as the textbook says. [–] suzuki 10y ago ↗ Certainly not. The foldl is a part of the TypeScript program that implements the Lisp.By the way, as for "while" in the implemented Lisp, it is defined with recursion and will be executed with tail-call optimization. See (defmacro while (test &rest body) (let ((loop (gensym))) `(letrec ((,loop (lambda () (cond (,test ,@body (,loop)))))) (,loop)))) in the const prelude of lisp.ts (http://www.oki-osk.jp/esc/typescript/lisp/lisp.ts.html). [–] junke 10y ago ↗ Thanks for this information.My point was more that map and reduce do not inherently require a recursive implementation and can be implemented directly as loops.I don't follow closely TypeScript: is tail-call merging done when compiling to Javascript or is the Javascript runtime responsible for this behavior? [–] suzuki 10y ago ↗ No, neither. That behavior is implemented in the same way as in the Lisp in Dart (http://www.oki-osk.jp/esc/dart/lisp-en.html#4).
[–] suzuki 10y ago ↗ Certainly not. The foldl is a part of the TypeScript program that implements the Lisp.By the way, as for "while" in the implemented Lisp, it is defined with recursion and will be executed with tail-call optimization. See (defmacro while (test &rest body) (let ((loop (gensym))) `(letrec ((,loop (lambda () (cond (,test ,@body (,loop)))))) (,loop)))) in the const prelude of lisp.ts (http://www.oki-osk.jp/esc/typescript/lisp/lisp.ts.html). [–] junke 10y ago ↗ Thanks for this information.My point was more that map and reduce do not inherently require a recursive implementation and can be implemented directly as loops.I don't follow closely TypeScript: is tail-call merging done when compiling to Javascript or is the Javascript runtime responsible for this behavior? [–] suzuki 10y ago ↗ No, neither. That behavior is implemented in the same way as in the Lisp in Dart (http://www.oki-osk.jp/esc/dart/lisp-en.html#4).
[–] junke 10y ago ↗ Thanks for this information.My point was more that map and reduce do not inherently require a recursive implementation and can be implemented directly as loops.I don't follow closely TypeScript: is tail-call merging done when compiling to Javascript or is the Javascript runtime responsible for this behavior? [–] suzuki 10y ago ↗ No, neither. That behavior is implemented in the same way as in the Lisp in Dart (http://www.oki-osk.jp/esc/dart/lisp-en.html#4).
[–] suzuki 10y ago ↗ No, neither. That behavior is implemented in the same way as in the Lisp in Dart (http://www.oki-osk.jp/esc/dart/lisp-en.html#4).
[–] hydandata 10y ago ↗ If you are interested in the future of Lisp in the context of browsers or Nodejs, take a look at this: http://lispblog.xach.com/post/138667931963/lisp-and-webassem...
13 comments
[ 2.8 ms ] story [ 42.7 ms ] threadI'm not complaining... just observing :).
> Any sufficiently complicated C or Fortran program contains an ad hoc, informally-specified, bug-ridden, slow implementation of half of Common Lisp.
isn't about the inevitability of literally implementing a Lisp interpreter.
It's about something more abstract. see: http://c2.com/cgi-bin/wiki?LevelsOfGreenspunning
... so that I would be technically correct. Which, as we all know, is the best kind of correct. (Source: Futurama)
> Every program attempts to expand until it can read mail. Those programs which cannot so expand are replaced by ones which can.
By the way, as for "while" in the implemented Lisp, it is defined with recursion and will be executed with tail-call optimization. See
in the const prelude of lisp.ts (http://www.oki-osk.jp/esc/typescript/lisp/lisp.ts.html).My point was more that map and reduce do not inherently require a recursive implementation and can be implemented directly as loops.
I don't follow closely TypeScript: is tail-call merging done when compiling to Javascript or is the Javascript runtime responsible for this behavior?