[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Robert Fischer <RFischer@R...> |
| Subject: | RE: [Caml-list] Operator overloading |
I didn't realize that existed. It's not so bad -- it lets me have my
cake and Jon eat it, too. :D
~~ Robert.
-----Original Message-----
From: caml-list-bounces@yquem.inria.fr
[mailto:caml-list-bounces@yquem.inria.fr]On Behalf Of Fernando Alegre
Sent: Thursday, March 08, 2007 4:25 PM
To: Jon Harrop
Cc: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] Operator overloading
On Thu, Mar 08, 2007 at 07:40:42PM +0000, Jon Harrop wrote:
> For me, operator overloading is about clarity. In the absence of
operator
> overloading, you cannot regain the lost clarity using modules and
functors.
I often use the poor man's local operator overloading already built into
the core OCaml:
let result =
let (+) = Vector.add and ( * ) (x:int) (v:Vector.t) =
Vector.scalarmul x v
in 3 * a + 2 * b
This makes overloading local and explicit, and at the same time makes
expressions clear. I do not miss implicit overloading.
Fernando
_______________________________________________
Caml-list mailing list. Subscription management:
http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
Archives: http://caml.inria.fr
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs