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
RE: [Caml-list] Operator overloading
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2007-03-09 (09:24)
From: skaller <skaller@u...>
Subject: Re: [Caml-list] Operator overloading
On Fri, 2007-03-09 at 08:23 +0100, Tom wrote:
> On 09/03/07, skaller <skaller@users.sourceforge.net> wrote:
>         BOTH Ocaml functors and overloading are just hacks to
>         work around the lack of ability to properly express
>         higher order natural transformations.
>  Hm... indeed, but for some operations, you cannot provide a single,
> general definition - say for length operation, or for * (* is very
> different when it comes to scalars, vectors and matrices - not even
> the same axioms hold). I believe that the basic operations should be
> implemented using overloading (actually, some smart overloading that
> would allow both static and (seemingly) dynamic resolving) and then
> polyadic operations be built on top of that. 

Actually, length can be defined in turns of fold:

let len x = fold (fun acc elt -> acc + 1) 0 container

John Skaller <skaller at users dot sf dot net>
Felix, successor to C++: http://felix.sf.net