(no) fast boolean evaluation ? missing NOT
Gabriel Genellina
gagsl-py2 at yahoo.com.ar
Sun Aug 5 06:05:08 EDT 2007
En Fri, 03 Aug 2007 11:56:07 -0300, Roel Schroeven
<rschroev_nospam_ml at fastmail.fm> escribió:
> Paul Boddie schreef:
>> On 3 Aug, 11:45, Stef Mientki <S.Mientki-nos... at mailbox.kun.nl> wrote:
>>> Sorry, my question missed the essential "NOT",
>>> here is an example, that behaves different in Delphi,
>>> (so I guess Delphi is not a real language ;-)
>>
>> Delphi is based on Pascal, and from what I can recall from my
>> university textbook, there isn't any mandatory short-circuit
>> evaluation in Pascal: it's an implementation-dependent feature.
>> Consequently, an expression involving boolean operators in such
>> languages may well evaluate each term (potentially causing side-
>> effects) before determining the final result.
>
> I even thought Pascal never uses short-circuit evaluation, and always
> evaluates all terms. I might be wrong about that though; it's been quite
> a long time since I've used Pascal.
Delphi defaults to short-circuit, but there is a compiler switch to make
it evaluate all the arguments.
But most people rely on this, and write code like:
if (MyObject <> nil) and (MyObject.Event <> nil) then MyObject.Event(Self);
and that would break if not short-circuited.
--
Gabriel Genellina
More information about the Python-list
mailing list