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

name that baby

Perhaps we should just go with the similarity of BABY-DOE and COMPOSE.

A multiple-values cognizant version of COMPOSE might be implemented as

     (define (compose g f)
       (lambda x (baby-doe (lambda () (apply g x)) f)))

(The argument order is the reverse of traditional COMPOSE.)  The
result of COMPOSE is a function that accepts as many arguments as
G.  The result of COMPOSE calls F on all the values returned by G.

Given this COMPOSE as primitive, we can define BABY-DOE as

  (define (baby-doe thunk bunk)
    ((compose thunk bunk))

Why not make COMPOSE the primitive and flush BABY-DOE?  Even with the
extra parens the name is half the length of "CALL-WITH-VALUE."  Or if
those extra parens bother you -- how did you get this far? -- then

   (define (compose-and-go a b)
     ((compose a b)))

Or how about this.  If we are going to rename VALUES to CONTINUE, then
rename BABY-DOE to CONTINUE-FROM or CONTINUING.  Then KMP's example

   (continuing (lambda () (continue 1 2)) cons)

But then why stop at two arguments?  COMPOSE is usually n-ary.

   (define (swap x y) (values y x))

   (continuing (lambda () (continue 1 2)) swap cons) 
   => (2 . 1)