comp.lang.ada
 help / color / mirror / Atom feed
* nasty language rules for fixed_type'last
@ 1989-01-27 16:24 linnig
  1989-01-30 15:45 ` Goodenough
  0 siblings, 1 reply; 2+ messages in thread
From: linnig @ 1989-01-27 16:24 UTC (permalink / raw)


I was astonished to learn that it is possible to raise an exception
by using 'FIRST or 'LAST on a fixed point type.  

Apparently, it is possible to specify a fixed point type that cannot
represent 'FIRST or 'LAST. The following is an example:


   1|PROCEDURE fixedtest IS
   2|TYPE f IS DELTA 1.0 RANGE 0.0 .. 32767.9; 
   3|
   4|x: f;
   5|BEGIN
   6| x:= f'last;
           ^1
***  1 Warn 4005: This operation will raise numeric_error at runtime because
***     of arithmetic overflow or because the result is not representable in
***     the target type format 
   7|END;
[TARTAN Ada VMS/1750A, Version V2.05]

The following paragraphs from the Ada LRM (3.5.9 and Appendix A) seems to
allow this behavior:

    "For a fixed point constraint that includes a range constraint, the
    model numbers comprise zero and all multiples of small whose mantissa
    can be expressed using exactly B binary digits, where the value of B is
    chosen as the smallest integer number for which each bound of the
    specified range is either a model number or lies at most small distant
    from a model number."

    "P'FIRST      For a prefix P that denotes a scalar type, or  a  subtype
                  of a scalar type:
                  Yields the lower bound of P.  The value of this attribute
                  has the same type as P.  (See 3.5.)"

For the language to allow 'FIRST and 'LAST to raise exceptions seems
very dangerous.  At least (for this example) it can be caught at compile
time.

	Mike Linnig,
	Texas Instruments

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: nasty language rules for fixed_type'last
  1989-01-27 16:24 nasty language rules for fixed_type'last linnig
@ 1989-01-30 15:45 ` Goodenough
  0 siblings, 0 replies; 2+ messages in thread
From: Goodenough @ 1989-01-30 15:45 UTC (permalink / raw)



In article nasty language rules for fixed_type'last of 27 Jan 89 16:24:00 GMT
linnig@skvax1.csc.ti.com writes:

>I was astonished to learn that it is possible to raise an exception
>by using 'FIRST or 'LAST on a fixed point type.  

Ada Commentary AI-00174 forbids an implementation from raising an exception
due to the evaluation of 'LAST or due to an assignment operation like that
given in your example.  This commentary has been approved by the Ada
Rapporteur Group and is to be considered for approval by the ISO standards
group for Ada (WG9) at its next meeting in June 1989.

John B. Goodenough					Goodenough@sei.cmu.edu
Software Engineering Institute				412-268-6391

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~1989-01-30 15:45 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1989-01-27 16:24 nasty language rules for fixed_type'last linnig
1989-01-30 15:45 ` Goodenough

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