comp.lang.ada
 help / color / mirror / Atom feed
* Constrained Boolean
@ 1987-04-07 14:14 firth
  1987-04-18  1:46 ` eric
  0 siblings, 1 reply; 4+ messages in thread
From: firth @ 1987-04-07 14:14 UTC (permalink / raw)


Just to correct a couple of minor errors in
a previous post

If somebody constrains a Boolean subtype
to one value, then the following holds

  . assignments must be checked (but the check
    is against a single value)

  . AND and OR need not be checked, assuming the
    operands are OK

  . NOT and XOR will always raise CONSTRAINT_ERROR

Procedure parameters are passed by value, so the
rules for assignment hold.

If the variable is an array of constrained Boolean
component subtype (phew!) then a component by
component check is needed in principle only on
assignment of an arbitrary value.  It is not
needed when the RHS is an expression involving
only similarly constrained array values.  On many
machines, these checks can be subsumed under a
block test for (all-zeros) or (all-ones), which
are the only legal aggregate values (assuming
the array is packed).

If the compiler cannot tell whether the Boolean
is constrained, then the proper discriminating
test is indeed "IF subtype'FIRST /= subtype'LAST".
Again, on some machines it might be prudent for
the compiler to compute the value of that expression
at the point where the subtype is declared.

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

end of thread, other threads:[~1987-04-20 14:01 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1987-04-07 14:14 Constrained Boolean firth
1987-04-18  1:46 ` eric
1987-04-18 12:38   ` Eric Marshall
1987-04-20 14:01     ` Robert Firth

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