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

Paul Rubin http
Thu Feb 19 14:00:03 EST 2004


Joe Mason <joe at notcharles.ca> writes:
> > 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.

That's merely a side effect of the parser not giving you a way to
capture the value of a while loop.  In Lisp, while loops return a
value.  In Python, the value is, heh, "implicitly" discarded.

> 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.

Is the value of "2+2" also not implicit by the same logic?  You're
using the word implicit in a pretty strange way, I think.

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

Never heard of setq?  ;-)

> 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.

I find the proposed new loop syntax very confusing.  I do see some
benefit for fixing up the initialization issue but think it should be
done at the top of the loop, not spread all through it.  C's 'for'
loop is better, because it puts that stuff at the top.  



More information about the Python-list mailing list