Version française
Home     About     Download     Resources     Contact us    
Browse thread
Compose function for multiple parameters ?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Martin Jambon <martin.jambon@e...>
Subject: Re: [Caml-list] Compose function for multiple parameters ?
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