----- Original Message -----
From: "Maximilian Wilson" <[EMAIL PROTECTED]>
To: "Anthony Borla" <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Sent: Saturday, December 03, 2005 3:11 PM
Subject: Re: Oz Newbie: Pattern Matching and Type Conversion

Max,

> > On 12/2/05, Anthony Borla <[EMAIL PROTECTED]> wrote:
> >
> > I *do* miss implict type conversion behaviour [e.g. C 'type
> > promotions'], and have been bitten [numerous times] by
> > simple code such as:
> >
> >     <float> / <int>
> >
>
> The thing about type conversions is that they can be lossy (i.e.
> lose information), and worse, they're silently lossy.
>

Which is, perhaps, one reason such things are eschewed by those writing
safety-critical applications where type-strict tools [such as, for example,
Ada] have tended to be used.

>
> I sometimes wonder whether the reason static typing is so
> popular in C and its descendants is because C is so quiet
> about type errors; it's *hard* to detect a stale pointer at
> runtime, and it's *hard* to detect that you're losing
> precision when you call a hypothetical abs(int) with
> -2.44 and come out with 2, so if someone
> is likely to make that error you provide an overloaded
> abs(double).
>

The C philosophy assumes the programmer knows what he is doing, so lets him
do it with a minimum of overhead and fuss. Whilst debugging might be more
difficult in such an environment, it does make for very lean, very high
performance software [once you get it right :) !].

>
> Perhaps one reason Mozart can get away
> with dynamic typing is because it will shout at you when
> you try to do arithmetic on Float |X| Int, so you don't get
> coerced Floats slowly infecting your data structures as
> they subvert Ints with their coercive propaganda,
> every time they're paired with one for a binary operation.
> This wouldn't matter so much if Floats didn't have such
> very different properties from Ints, unlike say fixed-point
> numbers... it makes it very difficult to reason about the
> semantics of your calculation.
>
> I am more and more coming to appreciate Mozart's strict
> aversion to arithmetic type coercion.
>

And, the reason [I strongly suspect] it's there, is to help provide a
guarantee the program is doing exactly what you want it to do, nothing more,
nothing less.

Cheers,

Anthony Borla


_________________________________________________________________________________
mozart-users mailing list                               
[email protected]
http://www.mozart-oz.org/mailman/listinfo/mozart-users

Reply via email to