[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Destructuring lambdas in T?



You could define your own special form, D-LAMBDA, which is
a "destructuring" lambda, in terms of DESTRUCTURE and LAMBDA.
For example:

        (define-syntax (D-LAMBDA args . body)
          (let ((real-args (map (lambda (x) (generate-symbol 'FOO)) args)))
            `(lambda ,real-args
              (destructure ,(map list args real-args)
                ,@body))))

This has the advantage that it checks for the correct number of 
arguments, but it still doesn't pretty-print the original source.
You also have to say 

        (define foo (d-lambda ((a b) c) (list a b c)))

instead of

        (define (foo ((a b) c))
            (list a b c))

I agree with Jim Meehan that it is undesirable to add destructuring
semantics to T's LAMBDA special form.

                                --- Jonathan