comp.lang.ada
 help / color / mirror / Atom feed
From: firth@sei.cmu.edu (Robert Firth)
Subject: Re: Constrained Boolean
Date: Mon, 20-Apr-87 09:01:34 EST	[thread overview]
Date: Mon Apr 20 09:01:34 1987
Message-ID: <1039@aw.sei.cmu.edu> (raw)
In-Reply-To: 3283@burdvax.PRC.Unisys.COM

In article <3283@burdvax.PRC.Unisys.COM> eric@burdvax.PRC.Unisys.COM (Eric Marshall) writes:
>last night I wrote:
>> 
>>   The elaboration of 'a' below will not raise CONSTRAINT_ERROR.
>> 
>>   subtype bool is boolean range true..true;
>>   a : bool := true xor false;
>
>	This is a poor example, although my point is correct, XOR
>will not always raise CONSTRAINT_ERROR. Below is a more appropriate
>example:
>
>		subtype bool is boolean range false..false;
>		a, b : bool := false;
>		c : bool := a xor b;

You're right, Eric, and I made a rather stupid error.  The original
discussion was about a Boolean subtype constrained to one value.
Indeed, XOR works iff that one value is FALSE, since FALSE xor FALSE
yields FALSE.

In the case of XOR between arrays, the code then becomes something
like

	if BOOLEAN_SUBTYPE'FIRST = TRUE then
		raise CONSTRAINT_ERROR;
	else
		null;	-- never any need actually to DO the assignment!
	end if;

(I hope)

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

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 message]
replies disabled

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