Thank you for your analysis, Shiro.

Looking at it, I think that everything fits perfectly. For right composition, function application has its argument on the right, so that we have to fold with `$` makes perfect sense. The operation that logically underlies left composition is function application where the argument is written on the left, which is exactly `$'` in your notation.

That `$` works for left composition as well when SRFI 1's fold is used is just due to the fact that SRFI 1's fold uses a non-natural argument ordering for its kons argument (it should really be xcons as in `fold-left`).


Am Fr., 22. Jan. 2021 um 12:24 Uhr schrieb Shiro Kawai <xxxxxx@gmail.com>:
I agree that we don't want to imply one being 'proper' and another being 'reverse'.   I also share Marc's feeling that compose>> and compose<< don't look like Scheme names we have.

I thought compose-left and compose-right, too, but one thing that bothers me is a slight discrepancy of nomenclature of 'fold' family.

We have three variants of 'fold' over a list:
 * srfi-1 fold
      (fold op x (list a b c)) == (op c (op b (op a x)))
 * r6rs fold-left
      (fold-left op x (list a b c)) == (op (op (op z a) b) c)
 * fold-right
      (fold-right op x (list a b c)) == (op a (op b (op c x))

If we have (define ($ f x) (f x)), then:  (I only consider 1 argument case for the simplicity)

   (compose-left f g h) == (lambda (x) (fold $ x (list f g h)))
   (compose-right  f g h) == (lambda (x) (fold-right $ x (list f g h)))

So,  we have this slightly assymetric correspondence:

   compose-left <---> fold
   compose-right <---> fold-right
   (none)  <---> fold-left

It may not be an issue if we consider an reverse of $: (define ($' x f) (f x)), then:

   (compose-left f g h) == (lambda (x) (fold-left $' x (list f g h)))
   (compose-right f g h) == (lambda (x) (fold-right $ x (list f g h)))

Would this be ok?








On Thu, Jan 21, 2021 at 9:34 PM Marc Nieper-Wißkirchen <xxxxxx@nieper-wisskirchen.de> wrote:
Am Fr., 22. Jan. 2021 um 02:40 Uhr schrieb John Cowan <xxxxxx@ccil.org>:
The trouble with "xcompose" is that it means "opposite of compose", but what is "compose"?  I think we should go with compose<< and compose>> in both SRFI 210 and SRFI 189.  These names are visually right-to-left or left-to-right.  That way, there is no ambiguity and no problem with backward compat to non-SRFIs.

You are, of course, right, when it comes to the meaning of "xcompose", which can only be guessed. Indeed, "compose<<" and "compose>>" look much clearer.

Yet, they don't look very Scheme-like to me.

I would then rather use

compose-left

and

compose-right

which are mathematical well-defined (and follow the fold-xxx naming scheme).

Right composition means that the argument to the function is on the right, left composition that the argument to the function is on the left. In mathematical notation, the former is given by $\circ$, the latter given by $;$ (borrowing from Z notation).

Can we agree on these names?

Marc