[Python-ideas] Statements vs Expressions... why?
bwinton at latte.ca
Wed Sep 10 21:47:19 CEST 2008
Cliff Wells wrote:
> I'd like to see things like "if" statements, "for" loops,
> etc, become expressions.
> Any thoughts on this? I'm sure it's been brought up before, but I
> haven't found any definitive discussions on why this rather arbitrary
> design decision continues to hold in the face of a general migration
> away from imperative languages (especially when it seems it could be
> changed without much backwards-compatibility issues).
Can you show me what an "if" in a "lambda" used in a function call would
look like? My major complaint with the statements-as-expressions is
that multi-line statements really don't look good when used in
expression contexts. Perhaps you have a good suggestion for the syntax,
and if so, I'ld love to see it.
> I've not delved into the internals of the Python interpreter to check,
> but I suspect that converting most statements to expressions would not
> be very difficult (changing the grammar definition and generated
> bytecode a small amount in most cases).
Well, I suspect that delving into the internals to check this theory
would make people take your proposal a lot more seriously. Heck, I'ld
go so far as to say that without doing that, it's all just talk, and
talk is cheap. ;)
More information about the Python-ideas