English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
'a Set?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2005-01-26 (12:04)
From: Jacques Garrigue <garrigue@m...>
Subject: Re: [Caml-list] 'a Set?
From: Radu Grigore <radugrigore@gmail.com>

> On Wed, 26 Jan 2005 11:13:58 +0100, Frédéric Gava
> <frederic.gava@wanadoo.fr> wrote:
> > When I teach Ocaml, many students are lost with
> > this differences.
> What puzzeled my is that List/String methods take the structure on
> which they act as the first parameter while the Set/Map methods take
> the structure on which they act as their last parameter. Is there a
> reason?

There seems to be an habit of having side-effecting functions take
their "object" as first parameter, while side-effect-free functions
take them as last.

One reason is that it is natural to specialize side-effecting function
on their "object", as it doesn't change (only its contents do), while
effect-free functions are best seen as transforming their object
(which should be last).

If you respect this convention, the type tells you about the semantics

Jacques Garrigue