comp.lang.ada
 help / color / mirror / Atom feed
From: AdaMagica <christoph.grein@eurocopter.com>
Subject: Re: Question on types conversions - operations
Date: Mon, 15 Jun 2009 03:33:19 -0700 (PDT)
Date: 2009-06-15T03:33:19-07:00	[thread overview]
Message-ID: <aec24860-d8af-41e7-a696-af9f0b7b6303@a36g2000yqc.googlegroups.com> (raw)
In-Reply-To: 6e151h.kgc.ln@hunter.axlog.fr

On Jun 15, 10:40 am, Jean-Pierre Rosen <ro...@adalog.fr> wrote:
> sjw a écrit :>> With S := Speed(Float(L) / Float(T)) ? Mmmm ... not nice.
>
> Why not nice? You are performing (for good reasons) a non homogenous
> operation. Therefore you go to the no-dimension world (convert to
> Float), do your operation there, then return to the dimensioned world
> (convert to Speed).

Of course not nice because: You introduce different types for safety
against mixing different units incorrectly. But then you render
physical expressions unreadable by marring them with type conversions
- and you lose type checking. So where is the safety?

This is only OK when hidden in a body for overloaded versions of
multiplying operators.

But then:
With only three dimensions, there are only a few overloadings
necessary; *but* there are also only very simple expressions so that
it's improbable that you write wrong expressions. So what do you gain?
Do you really gain something? Wrong dimensions deliver abstruse
results which should show up immediately in unit tests (when done
properly).

For more dimensions, you get a nightmare of overloadings. So IMHO it
is complete nonesense to try to implement different dimensions with
different types like this (with compile-time checking).

IMHO, there is no good way to do this in Ada as she is now.



  parent reply	other threads:[~2009-06-15 10:33 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-06-13 15:51 Question on types conversions - operations Olivier Scalbert
2009-06-13 16:13 ` Robert Matthews
2009-06-13 16:55 ` anon
2009-06-13 16:58 ` Dmitry A. Kazakov
2009-06-13 16:59 ` sjw
2009-06-13 17:24   ` Martin
2009-06-13 19:35     ` sjw
2009-06-14  8:22     ` sjw
2009-06-15  8:40   ` Jean-Pierre Rosen
2009-06-15  9:30     ` Olivier Scalbert
2009-06-15  9:51       ` stefan-lucks
2009-06-15 10:33     ` AdaMagica [this message]
2009-06-15 19:37     ` sjw
2009-06-13 19:56 ` Jeffrey R. Carter
2009-06-14 15:55   ` Robert A Duff
2009-06-15  8:52 ` AdaMagica
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox