comp.lang.ada
 help / color / mirror / Atom feed
From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: Syntax question:  new with a constrained subtype indication
Date: Mon, 25 Apr 2005 18:28:34 -0500
Date: 2005-04-25T18:28:34-05:00	[thread overview]
Message-ID: <LvqdnRiNhfAF4fDfRVn-gg@megapath.net> (raw)
In-Reply-To: 426d275e$0$1403$ba620e4c@news.skynet.be

"Adrien Plisson" <aplisson-news@stochastique.net> wrote in message
news:426d275e$0$1403$ba620e4c@news.skynet.be...
> Martin Dowie wrote:
> > What about 4.8(4):
> >
> >   "An initialized allocator is an allocator with a qualified_expression.
An
> >    uninitialized allocator is one with a subtype_indication. In the
> >    subtype_indication of an uninitialized allocator, a constraint is
> > permitted
> >    only if the subtype_mark denotes an unconstrained composite subtype;
> >    if there is no constraint, then the subtype_mark shall denote a
definite
> >    subtype."
>
> but this one does not forbid to write a scalar_constraint when the
> subtype_mark is a composite type...

Looking at the RM, I think that the rules for range_constraint cover this
(but not very clearly). The bounds of a the range have to have the type of
the subtype_mark - 3.5(5). Thus

     Vector range 1 .. 10;

is illegal, because "1" and "10" aren't Vectors. What is not certain to me
is why

    Vector range V1 .. V2;

is illegal. (It's nonsense, of course, but ignoring that...) 3.5(4) says
that a range specifies some subset of scalar values, but there don't seem to
be any rules that back this up (at least, I couldn't find any) - and 3.5(4)
is written in the conversational style of introductory text. I would have
expected a legality rule ("the bounds of a range shall have a scalar type"
or something like that) to reinforce this.

I guess I'll have to rely on Dewar's rule (the Standard never says anything
that requires nonsense) here. Still, 3.5(4) makes the intent clear, so it
doesn't seem worth fixing.

As previously noted, the constraint in an allocator is only permitted for
composite types, and a range must be scalar, so clearly you can't have a
range_constraint in an allocator.

                    Randy.








      reply	other threads:[~2005-04-25 23:28 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-04-25 15:44 Syntax question: new with a constrained subtype indication James Alan Farrell
2005-04-25 16:07 ` Alex R. Mosteo
2005-04-25 16:34   ` James Alan Farrell
2005-04-25 18:52     ` Martin Krischik
2005-04-26 14:17       ` James Alan Farrell
2005-04-25 16:18 ` Adrien Plisson
2005-04-25 16:37   ` James Alan Farrell
2005-04-25 17:16     ` Adrien Plisson
2005-04-25 16:34 ` Martin Krischik
2005-04-25 19:03   ` James Alan Farrell
2005-04-25 17:02 ` Martin Dowie
2005-04-25 17:22   ` Adrien Plisson
2005-04-25 23:28     ` Randy Brukardt [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