[Python-Dev] SETL (was: Lukewarm about range literals)

Tim Peters tim_one@email.msn.com
Tue, 29 Aug 2000 16:14:16 -0400


[Tim]
> ...
> Have always wondered why Python didn't have that [ABC's boolean
> quatifiers] too; I ask that every year, but so far Guido has never
> answered it <wink>.

[Guido]
> I don't recall you asking me that even *once* before now.  Proof,
> please?

That's too time-consuming until DejaNews regains its memory.  I never asked
*directly*, it simply comes up at least once a year on c.l.py (and has since
the old days!), and then I always mention that it comes up every year but
that Guido never jumps into those threads <wink>.  The oldest reference I
can find in DejaNews today is just from January 1st of this year, at the end
of

    http://www.deja.com/getdoc.xp?AN=567219971

There it got mentioned offhandedly.  Much earlier threads were near-PEP'ish
in their development of how this could work in Python.  I'll attach the
earliest one I have in my personal email archive, from a bit over 4 years
ago.  All my personal email much before that got lost in KSR's bankruptcy
bit bucket.

> Anyway, the answer is that I saw diminishing returns from adding more
> keywords and syntax.

Yes, I've channeled that too -- that's why I never bugged you directly
<wink>.



-----Original Message-----
From: python-list-request@cwi.nl [mailto:python-list-request@cwi.nl]
Sent: Saturday, August 03, 1996 4:42 PM
To: Marc-Andre Lemburg; python-list@cwi.nl
Subject: RE: \exists and \forall in Python ?!


> [Marc-Andre Lemburg]
> ... [suggesting "\exists" & "\forall" quantifiers] ...

Python took several ideas from CWI's ABC language, and this is one that
didn't
make the cut.  I'd be interested to hear Guido's thoughts on this!  They're
certainly very nice to have, although I wouldn't say they're of core
importance.  But then a lot of "nice to have but hardly crucial" features
did
survive the cut (like, e.g., "x < y < z" as shorthand for "x < y and y <
z"),
and it's never clear where to draw the line.

In ABC, the additional keywords were "some", "each", "no" and "has", as in
(importing the ABC semantics into a virtual Python):

if some d in range(2,n) has n % d == 0:
    print n, "not prime; it's divisible by", d
else:
    print n, "is prime"

or

if no d in range(2,n) has n % d == 0:
    print n, "is prime"
else:
    print n, "not prime; it's divisible by", d

or

if each d in range(2,n) has n % d == 0:
    print n, "is <= 2; test vacuously true"
else:
    print n, "is not divisible by, e.g.,", d

So "some" is a friendly spelling of "there exists", "no" of "not there
exists", and "each" of "for all".  In addition to testing the condition,
"some" also bound the test vrbls to "the first"  witness if there was one,
and
"no" and "each" to the first counterexample if there was one.  I think ABC
got
that all exactly right, so (a) it's the right model to follow if Python were
to add this, and (b) the (very useful!) business of binding the test vrbls
if
& only if the test succeeds (for "some") or fails (for "no" and "each")
makes
it much harder to fake (comprehensibly & efficiently) via map & reduce
tricks.

side-effects-are-your-friends-ly y'rs  - tim

Tim Peters    tim_one@msn.com, tim@dragonsys.com
not speaking for Dragon Systems Inc.