From: Robert Monfera
Subject: Re: thoughts on reference chaining and clos
Date: 
Message-ID: <38ED7BB8.5F9C300@fisec.com>
 Andrew K. Wolven wrote:

> [...] here goes:
>
> (obj foo bar baz)
>
> [...] as opposed to:
>
> (baz (bar (foo obj)))

[...]

> (I confess, I have had java/javascript and concepts of idl all floating
> through my brain at the same time)

Yes, that's the impression I got when reading the examples.  Wouldn't
COMPOSE be satisfactory?  At least I see MOP as too big a stone to kill
this bird, which would even miss it, not helping you with regular
functions.

(defun compose (&rest functions)
    (lambda (arg) (reduce #'funcall functions
                          :initial-value arg
                          :from-end t)))

e.g., (funcall (compose #'oddp #'1-) 4)  ->  T

(defmacro propagate (object &rest functions)
  `(funcall (compose ,@(nreverse (mapcar #'symbol-function functions)))
            ,object)

e.g., (propagate 4 1- oddp)  ->  T

which, in infix syntax, would be

4 propagate 1- propagate oddp

which is the same as

4.minusone.oddp

You can apply the macro character magic by Tim to allow

[4 1- oddp]

This is just an example, e.g., there may be a function name instead of
an object on the left too, but you have to make choices for namespaces
and the number of allowed arguments yourself.  In any case, you can
forget about multiple argument dispatching because of the
oversimplification COMPOSE means (giving you the message passing style).

Robert