News for hackers. Stuff that matters.
Re:Bill Clementson's Blog: JavaScript and Lisp by TNO on Friday December 11, 2009 @05:50PM (#990694)
Using JavaScript 1.8 expression closures:

  function Y(X)
      (function(procedure)
          X(function(arg) procedure(procedure)(arg)))
              (function(procedure)
                  X(function(arg) procedure(procedure)(arg)))
Re:Bill Clementson's Blog: JavaScript and Lisp by jdeseno on Friday December 11, 2009 @06:58PM (#990827)
Nice but, anonymous recursion is possible with arguments.callee.
Re:Bill Clementson's Blog: JavaScript and Lisp by benatkin on Saturday December 12, 2009 @04:38AM (#991375)
Re:Bill Clementson's Blog: JavaScript and Lisp by vlisivka on Saturday December 12, 2009 @07:02AM (#991435)
arguments.callee is deprecated in javascript 1.4. Use function name instead, so interpreter will have chance to perform tail recursion. Give names to your anonymous functions anyway: it will be much easier to trace them.

Example of anonymous recursive function with arguments.callee:

  var factorial=function(n) {
     return (!(n>1))? 1 : arguments.callee(n-1)*n;
  }
Example of anonymous recursive function without arguments.callee:

  var factorial=function factorial(n) {
     return (!(n>1))? 1 : factorial(n-1)*n;
 }
Re:Bill Clementson's Blog: JavaScript and Lisp by owinebarger on Friday December 11, 2009 @10:25PM (#991095)
Tried Doug Crockford's little Javascripter: (define loop (lambda (x) (loop x))) (loop 1)

Result in Firefox: "Too much recursion"

I'm still surprised I didn't flunk B521 when Dan Friedman put something like this in my Java implementation of a Scheme interpreter and it blew up after some finite number of iterations.

It might have worked if method calls were properly tail-recursive!

Re:Bill Clementson's Blog: JavaScript and Lisp by hypermatt on Friday December 11, 2009 @09:34PM (#991029)
Helped me find a cool video from this Waldemar Horwat guy. http://www.youtube.com/watch?v=Kq4FpMe6cRs
Re:Bill Clementson's Blog: JavaScript and Lisp by andrewcooke on Friday December 11, 2009 @07:56PM (#990926)
> will recognize that functions in JScript are fundamentally the Lambda Calculus

i would have thought you could say that about functions in any language...

Re:Bill Clementson's Blog: JavaScript and Lisp by mahmud on Friday December 11, 2009 @08:10PM (#990949)
Except languages where you can't pass functions as arguments or return them as results.
Re:Bill Clementson's Blog: JavaScript and Lisp by swannodette on Saturday December 12, 2009 @11:17AM (#991643)
Horror! I didn't know such atrocities existed shudder ;)
Re:Bill Clementson's Blog: JavaScript and Lisp by andrewcooke on Saturday December 12, 2009 @12:07PM (#991682)
you're right. i should have said "first class functions" (which narrows the field somewhat).
Re:Bill Clementson's Blog: JavaScript and Lisp by vlisivka on Saturday December 12, 2009 @06:53AM (#991432)
JavaScript is implementation of Scheme (dialect of Lisp) with Java-like syntax.
Re:Bill Clementson's Blog: JavaScript and Lisp by swannodette on Saturday December 12, 2009 @11:16AM (#991641)
Or as I like to say "JavaScript is Scheme in C drag".