[net.lang] IF KICK-BACK GREATER THAN 10 AND LESS THAN 100 THEN ...

guido@mcvax.UUCP (Guido van Rossum) (11/12/84)

In article <440@ima.UUCP> johnl@godot.UUCP writes:
>PS:  How many other languages let you write:
>
>	IF KICK-BACK GREATER THAN 10 AND LESS THAN 100 THEN ...
>
>without having to mention kick-back twice?  They don't design them like they
>used to.  Probably just as well.

Oh yes.  This language of ours, in which we have put every possible
effort to save the user's time and not the computer's, allows this:

	IF 10 < kick'back < 100: ...

It's about twice as short as the COBOL, and more readable, too!

--
	Guido van Rossum, "Stamp Out COBOL" Committee, CWI, Amsterdam, Holland
	guido@mcvax.UUCP

"Life is like a sewer.  What you get out of it, depends on what you put
 into it."

thomas@utah-gr.UUCP (Spencer W. Thomas) (11/12/84)

>In article <440@ima.UUCP> johnl@godot.UUCP writes:
>>PS:  How many other languages let you write:
>>
>>	IF KICK-BACK GREATER THAN 10 AND LESS THAN 100 THEN ...
>>
>>without having to mention kick-back twice?  

I've had this feature backfire on me, when I carelessly wrote

	IF A NOT EQUAL 10 OR 100 THEN ...

Look carefully - the above condition is always true!  You have to write
the less intuitive

	IF A NOT EQUAL 10 AND 100 THEN ...

>>					      They don't design them like they
>>used to.  Probably just as well.

Good thing.

=S

jack@vu44.UUCP (Jack Jansen) (11/13/84)

You can also do this in BCPL. If my memory is correct, you
can even go on with it, so write something like
IF 0 < LWB <= UPB <= 100 THEN ....

This is even more powerful than the COBOL feature, since
COBOL always uses the same expression on the lefthandside
of the condition.
-- 
	Jack Jansen, {seismo|philabs|decvax}!mcvax!vu44!jack
	or				       ...!vu44!htsa!jack
  "Only the great masters of style ever succeed in being obscure"
			Oscar Wilde, 1894.
  "Most unix(tm) programmers are great masters of style"
			Jack Jansen, 1984.

ken@ihuxq.UUCP (ken perlow) (11/21/84)

--
[In article <440@ima.UUCP> johnl@godot.UUCP writes]

>>PS:  How many other languages let you write:
>>
>>	IF KICK-BACK GREATER THAN 10 AND LESS THAN 100 THEN ...
>>
>>without having to mention kick-back twice?  

["=S", whoever that is, responds]

>> I've had this feature backfire on me, when I carelessly wrote
>> 
>>	IF A NOT EQUAL 10 OR 100 THEN ...
>>
>> Look carefully - the above condition is always true!  You have to
>> write the less intuitive
>> 
>> 	IF A NOT EQUAL 10 AND 100 THEN ...

The statistical package SPSS allowed such a short-cut, and I spent
at least half my time as a consultant trying to explain the rules
of logic to social science researchers who had committed just that
mistake.  Last I knew, SPSS's own consultants had themselves been
bothered so much by irate mis-programmers ("Hello?  SPSS?  Your
stat package doesn't work right!!") that they were determined
to remove the short-cut from future releases (next out was SPSS X).
Anybody know if they did?
-- 
                    *** ***
JE MAINTIENDRAI   ***** *****
                 ****** ******  20 Nov 84 [30 Brumaire An CXCIII]
ken perlow       *****   *****
(312)979-7188     ** ** ** **
..ihnp4!iwsl8!ken   *** ***

gvcormack@watdaisy.UUCP (Gordon V. Cormack) (11/22/84)

I am tired of people saying that this is the programmer's mistake.
COBOL is wrong.  Using the "rules of logic" gives the same result
as everyday common sense:  the opposite of what COBOL does.

The rules of logic say the following:  when you distribute a 
positive comparison like "less than" across a logical operator 
there is no problem.
 e.g.  A less than b and c   MEANS  A less than b and A less than c

However, if a negation is distributed across the logical operator,
DeMorgan's theorem applies; AND is transformed to OR and vice versa.
 e.g.  a not less than b and c
   
     MEANS (except in COBOL) a not less than b or a not less than c

but COBOL interprets it as

     a not less than b and a not less than c

An everyday example:

   Compare the meanings of:

     "I am not male and female"
     "I am not male or female"

-- Gordon Cormack, University of Waterloo

barmar@mit-eddie.UUCP (Barry Margolin) (11/27/84)

In article <6761@watdaisy.UUCP> gvcormack@watdaisy.UUCP (Gordon V. Cormack) writes:
>   Compare the meanings of:
>
>     "I am not male and female"
>     "I am not male or female"
>
>-- Gordon Cormack, University of Waterloo

The second is not good English.  It should be "I am neither male nor
female."
-- 
    Barry Margolin
    ARPA: barmar@MIT-Multics
    UUCP: ..!genrad!mit-eddie!barmar