comp.lang.ada
 help / color / mirror / Atom feed
From: firth@sei.cmu.edu.UUCP
Subject: Constrained Boolean
Date: Tue, 7-Apr-87 09:14:33 EST	[thread overview]
Date: Tue Apr  7 09:14:33 1987
Message-ID: <880@aw.sei.cmu.edu.sei.cmu.edu> (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.

             reply	other threads:[~1987-04-07 14:14 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1987-04-07 14:14 firth [this message]
1987-04-18  1:46 ` Constrained Boolean eric
1987-04-18 12:38   ` Eric Marshall
1987-04-20 14:01     ` Robert Firth
replies disabled

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