From: matt@... (matt neuburg) Date: 2006-10-28T06:30:14+09:00 Subject: Re: What are closures, continuations? Joe Ruby MUDCRAP-CE wrote: > One more question -- what are lambdas? This is a term from LISP. It basically just means a function that you can define and then pass around and call. In my previous example (about closures), the thing in curly braces, "{puts var}", was effectively a lambda. var = 7 p = Proc.new {puts var} def hereGoesNothing var = "yoho" yield end hereGoesNothing &p # => 7 var = 200 hereGoesNothing &p # => 200 ### def proc_maker var = 7 Proc.new {puts var} end p = proc_maker p.call # => 7 In the first example, I form the function, I assign it to a variable, and hand it (twice) to a method (hereGoesNothing) which calls it (yield). In the second example, I form the function and hand it out as the result of a method (proc_maker), assign it to a variable, and call it (call). LISPers like to celebrate this ability (among others) to treat a function just like any other Thing, passing it around and so forth, by chanting a poem (with apologies to JRR Tolkien) whose last three lines are: One Thing to name them all, One Thing to define them, One Thing to place them in environments and bind them, In the Lambda Order they are all first-class. m. -- matt neuburg, phd = matt@tidbits.com, http://www.tidbits.com/matt/ Tiger - http://www.takecontrolbooks.com/tiger-customizing.html AppleScript - http://www.amazon.com/gp/product/0596102119 Read TidBITS! It's free and smart. http://www.tidbits.com