Mashup the existing statement grammars to capture predicates
This is another suggestion for new syntax for assigning a name to the value of the predicate in an if, elif or while statement. It still uses `as` for its keyword, but with (more flexible) params instead of a direct assignment. It mashes up the if/while, def/class and for-in grammars, so it still looks like Python, and boils down to this: if|elif|while <predicate> as (<params>): <suite> If the params contain one simple name (the required minimum), the value of the predicate is assigned to that name. In any other case, the value must be a sequence, which gets unpacked: while input('$ ').split() as (command, *args): if run(command, parse(args)) as (result): render(result) else: sys.exit() -- Carl Smith carl.input@gmail.com
Nah??
-- Carl Smith
carl.input@gmail.com
On 24 May 2018 at 19:24, Carl Smith
This is another suggestion for new syntax for assigning a name to the value of the predicate in an if, elif or while statement. It still uses `as` for its keyword, but with (more flexible) params instead of a direct assignment.
It mashes up the if/while, def/class and for-in grammars, so it still looks like Python, and boils down to this:
if|elif|while <predicate> as (<params>): <suite>
If the params contain one simple name (the required minimum), the value of the predicate is assigned to that name. In any other case, the value must be a sequence, which gets unpacked:
while input('$ ').split() as (command, *args):
if run(command, parse(args)) as (result): render(result) else: sys.exit()
-- Carl Smith carl.input@gmail.com
Ah. Nice one. I'll look through that.
-- Carl Smith
carl.input@gmail.com
On 29 May 2018 at 19:52, Chris Angelico
On Wed, May 30, 2018 at 4:48 AM, Carl Smith
wrote: Nah??
Nah. It's already been discussed at interminable length as part of PEP 572. Feel free to browse that document.
ChrisA
participants (2)
-
Carl Smith
-
Chris Angelico