PEP-0315--Enhanced While Loop: An idea for an alternative syntax

Joe Mason joe at notcharles.ca
Thu Feb 19 05:45:31 EST 2004


In article <7xfzd7v21v.fsf at ruckus.brouhaha.com>, Paul Rubin wrote:
> No, I think he's preoccupied with distinctions that aren't there.
> He said
> 
>> x = 1 (or x := 1) looks to me like a statement that sets x to 1, not
>> an expression.  I wouldn't expect any return value, if my mind hadn't
>> been corrupted by C.
> 
> but of course from my Lisper's point of view, the whole idea that a
> statement and an expression are fundamentally different things is
> itself a sign of a corrupted mind.  I'm not willing to accept the

Aha!  Now I see.  Python is not Lisp.  It has tons of imperative
constructs that don't return values.  While loops, for instance.

Corrupt or not, though, the Lisp way is "everything implicitly returns a
value".  I'm not arguing for or against assignment expressions - I think
it's pretty trivial.  I'm just saying you can't claim they aren't
implicit.  And the Zen of Python has things to say about that.

As a Lisper, shouldn't you be avoiding assignments because of their
side effects anyway?  Surely you should be pushing for "let" bindings.

Speaking of which, even though I'm not particularly interested in new
syntax - break was fine for granpappy, and it's good enough for me -
let wouldn't be a bad keyword for the initialization section of the
loop.  Except that wouldn't mean exactly what it does in function
languages, which would be confusing.  "with" is another possibility -
the two uses I know are Pascal, where it just makes a record alias, and
Modula-3, where it works differently but I forget how.  But it's already
overloaded, anyway.

Joe



More information about the Python-list mailing list