Article View: comp.lang.misc
Article #977Re: do...while vs. repeat...until (was: Errors aren't that simple)
From: Mike Harrison
Date: Fri, 23 Mar 1990 12:51
Date: Fri, 23 Mar 1990 12:51
44 lines
2142 bytes
2142 bytes
In article <16249@haddock.ima.isc.com> karl@haddock.ima.isc.com (Karl Heuer) writes:
>(Followups to comp.lang.misc. I'm not talking about C; I'm talking about loop
>constructs in general.)
> ...
>To take a concrete example, let's ignore the existence of <ctype.h> and
>suppose that we want to test whether or not a given character is a lowercase
>letter. I claim that, to me, the condition "(c >= 'a' && c <= 'z')" is a
>simpler expression than "(c < 'a' || c > 'z')". I immediately recognize the
>idiom in the former, but the latter causes a perceptible delay as I mentally
>translate the condition. (If you disagree with this example, invent another
>one--unless you want to claim that there is *no* condition that is simpler
>than its inverse.)
But how about:
subtype LOWER_CASE_LETTERS is CHARACTER range 'a' .. 'z';
C : CHARACTER;
GET(C);
if C in LOWER_CASE_LETTERS then ...
(Guess which language :-))
For loop control structures I always liked Algol 68, where you could do all
the work in the Condition part, with an empty loop body, eg:
'while' 'if' a[i] > i 'then' i +:= 1; 'true' 'else' 'false' 'fi'
'do'
'skip'
'od'
And for the ultimate in conditional expressions:
'if' x = 1 'then' y 'else' z 'fi' := x;
Mike,
Michael P. Harrison - Software Group - Inmos Ltd. UK.
-----------------------------------------------------------
UK : mph@inmos.co.uk with STANDARD_DISCLAIMERS;
US : mph@inmos.com use STANDARD_DISCLAIMERS;
Technical Details
Message-ID:
<4879@ganymede.inmos.co.uk>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!mailrus!uunet!mcsun!ukc!icdoc!inmos!mph@lion.inmos.co.ukReferences:
<16188@haddock.ima.isc.com> <9130009@hpavla.AVO.HP.COM> <OVB2S3Bxds13@ficc.uu.net> <16249@haddock.ima.isc.com>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!mailrus!uunet!mcsun!ukc!icdoc!inmos!mph@lion.inmos.co.uk From: mph@lion.inmos.co.uk (Mike Harrison) Newsgroups: comp.lang.misc Subject: Re: do...while vs. repeat...until (was: Errors aren't that simple) Message-ID: <4879@ganymede.inmos.co.uk> Date: 23 Mar 90 12:51:41 GMT References: <16188@haddock.ima.isc.com> <9130009@hpavla.AVO.HP.COM> <OVB2S3Bxds13@ficc.uu.net> <16249@haddock.ima.isc.com> Sender: news@inmos.co.uk Reply-To: mph@inmos.co.uk (Mike Harrison) Organization: INMOS Limited, Bristol, UK. Lines: 44