[Python-ideas] Where-statement (Proposal for function expressions)
Paul Moore
p.f.moore at gmail.com
Wed Jul 15 12:25:04 CEST 2009
More information about the Python-ideas mailing list
Wed Jul 15 12:25:04 CEST 2009
- Previous message: [Python-ideas] Where-statement (Proposal for function expressions)
- Next message: [Python-ideas] Where-statement (Proposal for function expressions)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
2009/7/15 Carl Johnson <cmjohnson.mailinglist at gmail.com>: > It seems like for that case, we definitely want the "where" to apply > every time the generator expression loops though, but… Is that > feasible? To make the form follow the intent, the where block would need to be inside the [...] - which clearly violates the "no indented block structure within expressions" design rule. My initial instinct was that the original form violated that rule, too - but if you interpret the where block as a statement postfix, you're (almost) OK. The (almost) bit is because the where block has to be limited to simple (single-line) statements. But with those restrictions, the semantics become stmt where: a b c => a b c stmt with the proviso that variables defined in a,b,c are only available within a, b, c and stmt. But of course that immediately prompts the question: x = 1 y = x where: x = 2 print x What does that print? x = [] y = 1 where: x.append(1) print x What about that? x = [] y = x z = 1 where: x.append(1) print x, y, x is y And what about that??? And before someone points out Greg's proposal to limit the construct to "binding statements", please define (clearly) what is a "binding statement". And then explain how that helps if I replace x.append(1) with _ = x.append(1) in the above... I sort of like the idea, but it needs much better defined syntax and semantics if it's going to work. Paul.
- Previous message: [Python-ideas] Where-statement (Proposal for function expressions)
- Next message: [Python-ideas] Where-statement (Proposal for function expressions)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-ideas mailing list