caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Martin Jambon <martin.jambon@ens-lyon.org>
To: Fabrice Marchant <fabricemarchant@free.fr>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] Compose function for multiple parameters ?
Date: Sat, 31 May 2008 23:37:24 +0200 (CEST)	[thread overview]
Message-ID: <Pine.LNX.4.64.0805312316400.14886@martin.ec.wink.com> (raw)
In-Reply-To: <20080531180149.04e6ac5e@free.fr>

On Sat, 31 May 2008, Fabrice Marchant wrote:

> On Sat, 31 May 2008 13:24:55 +0200 (CEST)
> Martin Jambon <martin.jambon@ens-lyon.org> wrote:
>
>> On Sat, 31 May 2008, Fabrice Marchant wrote:
>>
>>>> It would be cooler to write the later on the basis of :
>>>> (( <<- ) (( <<- ) f)) g
>>>
>>> Sorry, I just discover that this is cleaner :
>>> (( <<- ) <<- ( <<- ))
>>>
>>> and extendable to any number of parameters.
>>>
>>> (( <<- ) <<- ( <<- ) <<- ( <<- ))
>>> to compose with a 3 parameters function.
>>
>> Personally, I call this obfuscated, not clean.
>>
>>
>> Martin
>
>  OK, it's far to be perfect - funny at best. But what would be the right way ?
>
> Defining the 2 ops :
> let ( <<- ) f g x = f (g x)
> let ( <<-- ) f g x y = f (g x y)
>
> is it better ?

Sorry Fabrice, I'm realizing that my answer was a bit rude...

My point is: why do you insist on having such operators? In my experience 
only the simple composition operator can be useful occasionally, locally.
Stuff that is not used frequently or which is used far from its point of 
definition should receive identifiers that mean something. So what I would 
do is use no operator at all unless you use it more than 5 times in the 
same module (more or less).

In other words, it's fun to play with such things, but in production code 
it's not useful except in some very special situations.


Martin

--
http://wink.com/profile/mjambon
http://mjambon.com


  parent reply	other threads:[~2008-05-31 21:40 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-05-31  7:24 Fabrice Marchant
2008-05-31  8:10 ` [Caml-list] " Fabrice Marchant
2008-05-31 11:24   ` Martin Jambon
2008-05-31 16:05     ` Fabrice Marchant
2008-06-01  8:39       ` Florent Monnier
     [not found]     ` <20080531180149.04e6ac5e@free.fr>
2008-05-31 21:37       ` Martin Jambon [this message]
2008-06-01  0:04         ` Robert Fischer
2008-06-01  5:24           ` Fabrice Marchant
2008-06-01  6:16         ` Fabrice Marchant

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Pine.LNX.4.64.0805312316400.14886@martin.ec.wink.com \
    --to=martin.jambon@ens-lyon.org \
    --cc=caml-list@inria.fr \
    --cc=fabricemarchant@free.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).