[racket-dev] Fancy application/automatic anonymous functions

From: Sam Tobin-Hochstadt (samth at ccs.neu.edu)
Date: Tue May 17 15:27:28 EDT 2011

On Tue, May 17, 2011 at 3:21 PM, Robby Findler
<robby at eecs.northwestern.edu> wrote:
> What is the rule for where the lambda goes?

If you have an application with one (or more) occurences of `_' as
immediate subforms, then that application is rewritten into (lambda
args the-original-application).

It doesn't attempt to do a deep inspection of the term, or to expand
the arguments to `#%app'.

Thus:

(+ _ 1) = (lambda (x) (+ x 1))

(+ (+ _ 1) 2) = (+ (lambda (x) (+ x 1)) 2) ;; which is a runtime error

This rule is (a) simple and (b) the same as what Scala does.
-- 
sam th
samth at ccs.neu.edu


Posted on the dev mailing list.