comp.lang.ada
 help / color / mirror / Atom feed
From: bobduff@world.std.com (Robert A Duff)
Subject: Re: 'Digit is generic package
Date: 1996/08/29
Date: 1996-08-29T00:00:00+00:00	[thread overview]
Message-ID: <DwwHDF.GuK@world.std.com> (raw)
In-Reply-To: 4vj3e6$hi1@goanna.cs.rmit.edu.au


In article <4vj3e6$hi1@goanna.cs.rmit.edu.au>,
Richard A. O'Keefe <ok@goanna.cs.rmit.edu.au> wrote:
>(a) I would get some consolation from knowing whether this was an *intended*
>    restriction for Ada 95 and if so what harm would have resulted had this
>    restriction not been in the language.

This restriction comes from Ada 83, and as far as I know, nobody wanted
to change it for Ada 9X.  I recall some earlier version of Ada 83 (Ada
80, or Green, or something) was more liberal, along the lines you're
asking for.  I don't remember the exact rules, but I think it was
possible to say things like "type T is digits X;" where X was a generic
formal parameter.  You could look at the old pre-1983 documents...

The reason for the rule is essentially just to keep things simple, I
think.  It would be more complicated to describe a rule that allowed
some expressions to be static, depending on knowing that they will be
static in the instance.  And it would probably be harder to implement.
Also, if you allowed what you want in a generic body, then it would
violate the contract model, and cause trouble for code-sharing
implementations.

In general, the definition of "static expression" was never intended to
be "any expression that can be evaluated at compile time" -- just a
reasonably useful, but not-too-hard-to-implement subset of those
expressions.  For example, composite expressions are never static in Ada
83, and in Ada 95, are static only in some severely-restricted string
cases.

>(b) Is there any better approach for doing this with a procedure than the
>    make-to-instances-and-pick-one-at-runtime one shown above?

I think your best bet is to pass in three types, and check at run time
that their 'Digits have the right relationship.  That's not *so* awful.

- Bob




      parent reply	other threads:[~1996-08-29  0:00 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-08-23  0:00 'Digit is generic package Richard A. O'Keefe
1996-08-24  0:00 ` Robert I. Eachus
1996-08-29  0:00 ` Robert A Duff [this message]
replies disabled

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