[Python-ideas] Statements vs Expressions... why?
Cliff Wells
cliff at develix.com
Sun Sep 14 00:17:42 CEST 2008
On Sat, 2008-09-13 at 19:01 +0100, Arnaud Delobelle wrote:
> On 10 Sep 2008, at 22:22, Cliff Wells wrote:
>
> > On Wed, 2008-09-10 at 21:46 +0200, Christian Heimes wrote:
> >> Cliff Wells wrote:
> >>> 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).
> >>
> >> Two thoughts:
> >>
> >> Please elaborate how you like to change the syntax of Python.
> >
> > No changes. Simply lifting of a particular restriction.
> >
> >> I like to
> >> see some concrete examples how your syntax would look like. I also
> >> like
> >> to know how your are planing to implement features like lazy
> >> evaluation.
> >> The if else ternary operator statement is evaluated lazy. The same
> >> construct as expression wouldn't be lazy any more.
> >
> > Why not?
> >
> > a = (
> > if a > 1 then:
> > long_calculation()
> > else:
> > other_long_calculation()
> > )
> >
> > Clearly only one of these blocks would be evaluated at runtime.
>
> So what does:
>
> a = (if False: 1)
>
> evaluate to?
That's a good question. This is one of those areas where a definition
would need to be created. My inclination is to say None (much like a
function with no return statement).
Cliff
More information about the Python-ideas
mailing list