comp.lang.ada
 help / color / mirror / Atom feed
From: eric@burdvax.UUCP
Subject: Re: language problem
Date: Mon, 6-Apr-87 08:26:19 EST	[thread overview]
Date: Mon Apr  6 08:26:19 1987
Message-ID: <3223@burdvax.PRC.Unisys.COM> (raw)
In-Reply-To: 6109@mimsy.UUCP

in article <6109@mimsy.UUCP>, dday@mimsy.UUCP (Dennis Doubleday) says:
> ....  But if it is impossible to efficiently handle
> type and constraint checking for every possible pathological
> boundary condition ...

At least in this example, the compiler can determine if the situation
could occur at execution time, and take appropriate actions by
emitting code for the efficient common situation, or less efficient
code for the pathological case.

First, the only operators which can partake in this silliness
are NOT and XOR, and only if their operand(s) is a subtype of
a boolean type constrained to a single value (Yuch). If such
a type may exist at execution time, the compiler could emit an
if statement like the following.

	if funny_boolean_type'first != funny_boolean_type'last then
		emit efficient code for AND and XOR
	else
		emit funny code for AND and XOR
	end if;

The funny code for AND is easy, just raise CONSTRAINT_ERROR (what
could be more efficient than that :-). For XOR, a component by
component test needs to be performed for the detection of
CONSTRAINT_ERROR.

So it turns out, for efficiency at least, that the XOR operation
is the worst case, AND is the best case, and for the common case
(a boolean type with both values), an additional if statement
is needed. Remember, all of this is only for a boolean type which
could turn out to be constrained to only a single value.


Eric Marshall
Unisys Corporation
P.O. Box 517
Paoli, PA. 19301
(215) 648-7223

USENET: sdcrdcf!burdvax!eric
        {sjuvax,ihnp4,akgua,cadre}psuvax1!burdvax!eric
ARPANET: eric@burdvax.prc.unisys.com

  reply	other threads:[~1987-04-06 13:26 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <12291366595.33.BRYAN@Sierra.Stanford.EDU>
1987-04-02 20:22 ` language problem ROSENBLUM
1987-04-03 14:49   ` dday
1987-04-06 13:26     ` eric [this message]
1987-04-08 18:08 drw
  -- strict thread matches above, loose matches on Subject: below --
1987-04-07  5:53 drw
1987-04-08  1:11 ` keith
1987-04-03 10:35 ms8k#
1987-04-01 23:58 ms8k#
1987-04-03  0:52 ` deller
1987-03-26 17:30 amiram
1987-04-01 15:05 ` joe
1987-04-01 20:12   ` cjh
replies disabled

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