From: "Grein, Christoph" <christoph.grein@eurocopter.com>
Subject: Re: Announce: The Ultimate SI Units Cracker
Date: Fri, 13 Sep 2002 06:53:50 +0200 (MET DST)
Date: 2002-09-13T06:53:50+02:00 [thread overview]
Message-ID: <mailman.1031893204.31270.comp.lang.ada@ada.eu.org> (raw)
From: Wes Groleau <wesgroleau@despammed.com>
>
> Since Ada has a 'special' meaning for attribute, perhaps
> 'component' or 'discriminant' would be better.
Perhaps 'component', but not 'discriminant', since only one variant really uses
discriminants.
I decided against component, because the type is private and you do not see
components. I used attribute since the OO community likes to call what Ada does
with components, instance attributes.
> Anyway, looks nice. I once implemented a package with
> the 'derived types' approach, and I agree that creating
> all the operations is a pain. I had a generic for each operator,
> but it was Ada 83, so the instantiations had to be in the spec,
> making the spec over 4,000 lines long. Someone with a little
> authority thought a 4,000 line spec was unacceptable, so he
> rewrote it non-generic, reducing the spec down to "only" 3,000
> lines (and increasing the body from less than 50 to over 5,000).
And what's most unsatisfactory is that despite all these overloadings, you
cannot get
function "**" (Base: SI_Unit; Exp: Rational) return SI_Unit;
> I like the discriminant approach, but it does have another
> disadvantage in that a lot of numeric operations are lost.
>
> You can't query 'First, 'Last, 'Small, etc. But maybe when
> dealing with physical units those don't really matter much.
> And of course the package can provide substitutes.
>
> You also can't provide such a type as a generic formal
> where a float or fixed is expected. (Speaking of which,
> perhaps a fixed-point version of SI would be useful to someone.)
>
> ... [text omitted]
>
> What I'm getting at is the ability to define a private type
> so that it has all the attributes and operations of a numeric
> type and can be use as a generic parameter to a numeric package.
That would be really cool, perhaps with some Ada0Y features...
But then it's not clear what e.g. a generic should do with the non-numeric
components. It could just ignore them. But then how should a function know what
to return if the actual for the formal T is SI_Unit?
generic
type T is digits <>;
function F (X, Y: T) return T;
Perhaps this could work only for a private type that is tagged. Would this be a
proposal for Ada0Y? If so, we would need a convincing example for the ARG of a
problem that can be solved with such a new feature that cannot be solved nicely
without it...
next reply other threads:[~2002-09-13 4:53 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-09-13 4:53 Grein, Christoph [this message]
2002-09-13 14:34 ` Announce: The Ultimate SI Units Cracker Ira Baxter
2002-09-13 20:50 ` Stephen Leake
2002-09-16 10:22 ` Fraser Wilson
2002-09-13 15:41 ` Wes Groleau
-- strict thread matches above, loose matches on Subject: below --
2002-09-13 5:34 Grein, Christoph
2002-09-12 11:59 Grein, Christoph
2002-09-12 11:51 Grein, Christoph
2002-09-12 8:11 Grein, Christoph
2002-09-12 10:14 ` Preben Randhol
2002-09-12 10:50 ` Jeffrey Creem
2002-09-12 14:06 ` Wes Groleau
2002-09-12 17:06 ` Randy Brukardt
2002-09-13 15:20 ` Wes Groleau
2002-09-13 20:54 ` Randy Brukardt
2002-09-13 22:09 ` Dmitry A.Kazakov
2002-09-13 15:26 ` Wes Groleau
2002-09-15 6:21 ` Dmitry A.Kazakov
2002-09-15 0:24 ` Mark Biggar
2002-09-16 1:35 ` Dmitry A.Kazakov
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox