comp.lang.ada
 help / color / mirror / Atom feed
* CONSTRAINT ERROR raised at runtime
@ 1986-01-23  3:27 Neil on 225-7155
  1986-01-24 18:37 ` Mark Biggar
  0 siblings, 1 reply; 2+ messages in thread
From: Neil on 225-7155 @ 1986-01-23  3:27 UTC (permalink / raw)


>    LNTH : NATURAL range 1..8 := 0;

In the index of ANSI/MIL-STD-1815A-1983 (The Programming Language
Ada Reference Manual), under the entry CONSTRAINT_ERROR, is a reference
to "raised by the initialization of an object 3.2.1".

In that section, paragraph 16, it says "The initialization of an object
... checks that the initial value belongs to the subtype of the
object ... The exception CONSTRAINT_ERROR is raised if this check fails."

I take "The initialization..." to be a reference to the run-time
behaviour. Since the run-time environment raises CONSTRAINT_ERROR, I think
the compiler behaves correctly.

Of course, if your question was "Why is Ada not defined differently?",
rather than why does the compiler not complain, I would not pretend to know
the answer. My experience is that these questions always have good, but
not obvious, answers.

				Neil Cook

Of course, these are my opinions, and nothing to do with anyone else.
DEC Ada is nothing to do with me. DEC and Ada are trademarks of DEC and
The United States Government, Department of Defense, Under Secretary for
Research and Engineering, respectively.

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

* Re: CONSTRAINT ERROR raised at runtime
  1986-01-23  3:27 CONSTRAINT ERROR raised at runtime Neil on 225-7155
@ 1986-01-24 18:37 ` Mark Biggar
  0 siblings, 0 replies; 2+ messages in thread
From: Mark Biggar @ 1986-01-24 18:37 UTC (permalink / raw)


In article <640@decwrl.DEC.COM> cook@katie.DEC (Neil on 225-7155) writes:
>>    LNTH : NATURAL range 1..8 := 0;
>
>In the index of ANSI/MIL-STD-1815A-1983 (The Programming Language
>Ada Reference Manual), under the entry CONSTRAINT_ERROR, is a reference
>to "raised by the initialization of an object 3.2.1".
>
>In that section, paragraph 16, it says "The initialization of an object
>... checks that the initial value belongs to the subtype of the
>object ... The exception CONSTRAINT_ERROR is raised if this check fails."
>
>I take "The initialization..." to be a reference to the run-time
>behaviour. Since the run-time environment raises CONSTRAINT_ERROR, I think
>the compiler behaves correctly.

A very close reading of the LRM shows that there is no reason why the
compiler shouldn't complain, it just doesn't have to.  Section 1.6 para 5
says:

"If an exception is certain to be raised in every execution of a program,
 then compilers are allowed (although not required) to report this fact
 at compilation time."

So the compiler DOES behave correctly, it just could have behaved in a more
user friendly way then it did.

Mark Biggar
{allegra,burdvax,cbosgd,hplabs,ihnp4,akgua,sdcsvax}!sdcrdcf!markb

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

end of thread, other threads:[~1986-01-24 18:37 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1986-01-23  3:27 CONSTRAINT ERROR raised at runtime Neil on 225-7155
1986-01-24 18:37 ` Mark Biggar

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