comp.lang.ada
 help / color / mirror / Atom feed
From: Adam Beneschan <adam@irvine.com>
Subject: Re: Subtypes boundaries
Date: Mon, 14 Jun 2010 18:20:36 -0700 (PDT)
Date: 2010-06-14T18:20:36-07:00	[thread overview]
Message-ID: <067016cf-ee12-422d-85c0-9017cf87f24f@40g2000pry.googlegroups.com> (raw)
In-Reply-To: 87o1v9FvpjU1@mid.individual.net

On Jun 14, 6:05 pm, Nobody <nob...@nowhere.org> wrote:
> On Tue, 15 Jun 2010 01:31:47 +0200 Yannick Duchêne (Hibou57) wrote:
>
> > [ARM 2005 3.5(5)] just says:
> >> For a subtype_indication containing a range_constraint, either directly
> >> or as part of some other scalar_constraint, the type of the range shall
> >> resolve to that of the type determined by the subtype_mark of the
> >> subtype_indication.
>
> The annotated ARM says:
>
> 3.5 Scalar Types, 8.a
> Ramification: Only range_constraints (explicit or implicit) impose
> conditions on the values of a scalar subtype. The other
> scalar_constraints, digit_constraints and delta_constraints impose
> conditions on the subtype denoted by the subtype_mark in a
> subtype_indication, but don't impose a condition on the values of the
> subtype being defined. Therefore, a scalar subtype is not called
> constrained if all that applies to it is a digits_constraint. Decimal
> subtypes are subtle, because a digits_constraint without a
> range_constraint nevertheless includes an implicit range_constraint.
>
> What I understand is that a subtype shall in maximum contain all values
> of the subtype indicator, i.e. the superordinated type. Therefore the
> definition
>
> type ASTERIX range +5_000..10_000;
> subtype IDEFIX is ASTERIX range 1..20_000;
>
> should in ANY case cause a compile time error!!!

3.5(8), which you're reading, is in a "Dynamic Semantics" section.
Whatever you see there explains how the program will behave at run
time.  Nothing in a Dynamic Semantics section should ever affect
whether you get an error at compile time or not, I think.  The rules
that cause compile-time errors are in "Legality Rules" sections, and
perhaps in "Static Semantics".

As for why this would cause an error at run time but not at compile
time, I've tried to explain already why it might be a good idea to
have the language rules this way.  What this means is that if your
compiler tells you that something you wrote will raise an exception at
run time, take it seriously, as seriously as you'd take an actual
error.

                                   -- Adam




      reply	other threads:[~2010-06-15  1:20 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-06-14 20:25 Subtypes boundaries Nobody
2010-06-14 20:36 ` Jeffrey R. Carter
2010-06-17 18:54   ` Nobody
2010-06-17 18:58     ` Nasser M. Abbasi
2010-06-17 19:17     ` Jeffrey R. Carter
2010-06-17 19:53     ` Ludovic Brenta
2010-06-14 20:43 ` Nobody
2010-06-14 21:01   ` Gautier write-only
2010-06-14 23:31     ` Yannick Duchêne (Hibou57)
2010-06-15  0:01       ` Peter C. Chapin
2010-06-15  0:58         ` Adam Beneschan
2010-06-15  1:05       ` Nobody
2010-06-15  1:20         ` Adam Beneschan [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