comp.lang.ada
 help / color / mirror / Atom feed
From: ncohen@watson.ibm.com (Norman H. Cohen)
Subject: Re: DECAda/VMS - calling GETJPI
Date: 1996/06/07
Date: 1996-06-07T00:00:00+00:00	[thread overview]
Message-ID: <4p9k71$11a1@watnews1.watson.ibm.com> (raw)
In-Reply-To: 4p547s$n99@krusty.irvine.com


In article <4p547s$n99@krusty.irvine.com>, adam@irvine.com
(Adam Beneschan) writes: 

|> mfb@mbunix.mitre.org (Michael F Brenner) writes: 
...
|>  >Paragraph 28 of Section 4.6 states that constraint_error on conversion
|>  ><can only happen on conversion to a modular type>. This is a typographical
|>  >error. It makes no sense, and it contradicts both the above three
|>  >paragraphs in the Reference Manual, and it contradicts the fact that
|>  >constraint_error is raised only on converting to a non-modular type.
|>  >
|>  >It should be changed to read <can only happen on conversion to a
|>  >non-modular type>.
|>
|> I'm not qualified to determine whether this is a typo.  Actually, the
|> only people that can say for sure are those involved in writing the
|> RM.  I'll have to admit that I don't know what the paragraph as
|> written means.

It's not a typo, but it is a case of the RM getting overly pedantic and
obscure.  For reasons that Tucker may remember but I do not, all numeric
types other than modular types are described as having an infinite "set
of values", some of which belong to a finite "base range": 

   RM95 3.5.4(8): "The set of values for a signed integer type is the
      (infinite) set of mathematical integers, though only values of the
      base range of the type are fully supported for run-time operations.
      The set of values for a modular integer type are the values from 0
      to one less than the modulus, inclusive."

   RM95 3.5.6(8): "The set of values of a floating-point type is the
      (infinite) set of rational numbers."

   RM95 3.5.9(8): "The set of values of a fixed-point type comprise
      integral multiples of number called the _small_ of the type."

(Base ranges are described in RM95 3.5(6).)

Thus RM95 4.6(28) is correct when it states: 

    "If there is no value of the target type that corresponds to the
    operand value, Constraint_Error is raised.  This can only happen on
    conversion to a modular type, and only when the operand value is
    outside the base range of the modular type."

(Nonnumeric value conversions are always to a target type that has a
corresponding value for each value of the operand type.  Since all
numeric types other than modular types are conceptually infinite,
conversions to a numeric type other than a modular type are always to
such a target type; conversions to a modular type are not.)  The word
"This" in 4.6(28) refers to the raising of Constraint_Error specifically
because there is no corresponding value in the target type, not to the
raising of Constraint_Error in general.

Yet we all know that given the declaration

   type T is range 1 .. 10;

the conversion T(11) raises Constraint_Error, so what's going on here?
The answer is found in RM95 4.6(51): "After conversion of the value to
the target type, if the target subtype is constrained, a check is
performed that the value satisfies this constraint."

In short, a value conversion consists of converting to the target type,
which can only raise Constraint_Error when the target type is a modular
type, followed by a check that the converted value obeys the constraint
of the target subtype, which generally has the potential to raise
Constraint_Error for any target type.

--
Norman H. Cohen    ncohen@watson.ibm.com




  reply	other threads:[~1996-06-07  0:00 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-06-03  0:00 DECAda/VMS - calling GETJPI Alan Paterson
1996-06-03  0:00 ` Ken Garlington
1996-06-03  0:00 ` Stuart Palin
1996-06-03  0:00   ` Michael F Brenner
1996-06-03  0:00     ` Robert Dewar
1996-06-04  0:00       ` Michael F Brenner
1996-06-04  0:00         ` Robert Dewar
1996-06-04  0:00           ` Michael F Brenner
1996-06-04  0:00             ` Robert Dewar
1996-06-05  0:00               ` Fergus Henderson
1996-06-05  0:00                 ` Robert A Duff
1996-06-05  0:00               ` Robert A Duff
1996-06-05  0:00                 ` Robert Dewar
1996-06-05  0:00               ` Wraparound on modular conversion (was: DECAda/VMS - calling GETJPI) Tucker Taft
1996-06-05  0:00                 ` Robert Dewar
1996-06-04  0:00             ` DECAda/VMS - calling GETJPI Robert Dewar
1996-06-05  0:00             ` Adam Beneschan
1996-06-07  0:00               ` Norman H. Cohen [this message]
1996-06-11  0:00                 ` Adam Beneschan
1996-06-04  0:00       ` Ken Garlington
1996-06-06  0:00         ` Robert Dewar
1996-06-03  0:00 ` Mats Weber
  -- strict thread matches above, loose matches on Subject: below --
1996-06-06  0:00 George Haddad
1996-06-07  0:00 ` Robert Dewar
replies disabled

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