[comp.lang.scheme] lambda*, where is it now ... ?

bevan@cs.man.ac.uk (Stephen J Bevan) (06/04/91)

I've finished just reading% :-

A Variable-Arity Procedural Interface
R. Kent Dybvig and Robert Hieb
Procedings of ACM Conference on Lisp and Functional Programming
1988

and I was wondering has anything been done with `lambda*' since then.
i.e. has it been implemented in any Scheme (Chez maybe?) and does
anbody have any experience with it.  Or has it been abandonded in
favour of something else?

Stephen J. Bevan			bevan@cs.man.ac.uk

% Not being `big' in Lisp, we (Manchester) only recently got the
  proceedings, and we are still waiting for 86 and 90!

mike@claven.cambridge.ibm.com (Mike Wojcik) (06/14/91)

When I was taking my (undergraduate) Analysis of Programming Languages class,
the instructor (a grad student) implemented lambda* in both PCScheme and some
Scheme variant on the Suns.  I was partially successful at implementing it
myself.  Unfortunately, I don't have his version, but my experiments were
along the line of

--- cut here ---

;;; lambda*:  a generator of self-currying procedures
;;; eg. (define f (lambda* (x y) (+ x y))) creates a procedure f w/ the
;;; following properties:
;;;    (f) == f
;;;    (f p1 p2) == (+ p1 p2)
;;;    (f p1) == (lambda* (y) (+ p1 y))  [i.e. another self-currying proc.]
(extend-syntax (lambda*)
  [(lambda* (p1 p2) exp)                ;base case -- 2 parameters
   (with ([f-func (gensym)]
          [g-func (gensym)]
          [f-parms (gensym)]
          [g-parms (gensym)])
     (letrec ([f-func
       (lambda f-parms
         (case (length f-parms)
           [0 f-func]                   ;(f) -> f
           [1 (letrec ([g-func          ;(f p1) -> a new lambda* procedure
             (lambda g-parms
               (case (length g-parms)
                 [0 g-func]
                 [1 ((lambda (p2) ((lambda (p1) exp) (car f-parms)))
                   (car g-parms))]      ;((f p1) p2) -> application
                 [else (error 'g "too many parameters")]))])
             g-func)]
           [2 ((lambda (p2) ((lambda (p1) exp) (car f-parms))) (cadr f-parms))]
           [else (error 'f "too many parameters")]))])
        f-func))]
  [(lambda* (p1 p2 p3 ...) exp)         ;extended case: recurse on lambda*
                                        ;  model until only 2 formal param-
                                        ;  eters; resulting proc. will apply
                                        ;  actual params. to nested lambda*'s
                                        ;  until they reach the f/g case
   (with ([e-func (gensym)]
          [e-parms (gensym)])
     (letrec ([e-func
       (lambda e-parms
         (case (length e-parms)
           [0 e-func]
           [else (apply (lambda* (p2 p3 ...) ((lambda (p1) exp) (car e-parms)))
             (cdr e-parms))]))])
       e-func))])

--- end cut ---

Mike Wojcik
-- 
Michael Wojcik
I do not represent IBM, or DEC, or Sun, or HP, or . . .