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: entiers et reels
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 1996-01-07 (23:49)
From: Thorsten Ohl <ohl@c...>
Subject: Re: entiers et reels

>>>>> "Pierre" == Pierre Weis <Pierre.Weis@inria.fr> writes:

Pierre> En revanche il n'y a pas de sens raisonable a` une addition
Pierre> polymorphe, et c'est pourquoi nous avons une collection
Pierre> d'additions monomorphes.

 [ No, I'm not going to embarrass myself by trying to respond in
   French ... :-) ]

Maybe I'm too dense or I have been exposed to too much Fortran, but I
don't fully understand:

Standard ML has it (at least in the New Jersey incarnation), so why
can't Caml?  As long as all operands are of the same type, the
semantics should be obvious.

I agreee that promotion will open a can of worms (standard example:
(1/2)*2.0 would most likely evaluate to 0.0, which is even more likely
_not_ what the programmer intended).  But wouldn't it be possible to
assign types to subexpressions based on the context in such a way that
no information can be lost?

I asking out of curiosity, but from the user's perspective I want to
add that polymorphic arithmetic is just soooo convenient.  It can be
abused, but it can also make programs much more readable, if used with
discretion.  In particular if types have a natural inclusion (like
natural, integer, rational, real and complex numbers).  Also for
vector spaces: it is usually not ambigious whether a scalar or an
inner product is intended.


/// Thorsten Ohl, TH Darmstadt, Schlossgartenstr. 9, D-64289 Darmstadt, Germany
//// http://crunch.ikp.physik.th-darmstadt.de/~ohl //// voice: +49-6151-16-3116
///// email: Thorsten.Ohl@Physik.TH-Darmstadt.de /// secretary: 2072, fax: 2421