[prev in list] [next in list] [prev in thread] [next in thread] 

List:       python-ideas
Subject:    Re: [Python-ideas] Saving state in list/generator comprehension
From:       Nick Coghlan <ncoghlan () gmail ! com>
Date:       2012-06-11 6:45:46
Message-ID: CADiSq7e7KJCDYAZPLpfJxAAO38N+VcuNooKo9Ny26_3KCnmn_Q () mail ! gmail ! com
[Download RAW message or body]

On Mon, Jun 11, 2012 at 1:09 PM, Andrew Carter <acarter@cs.hmc.edu> wrote:
> =A0I feel like there is a need from personal experience of mapping with s=
tate
> in a short concise way. However it is quite possible that it is just me, =
and
> I need to think about the problem differently, or perhaps live with 4 line
> functions that are only used once.=A0As for the backwards compatibility I
> think was getting ahead of myself,=A0I feel the with/as solution is quite
> clunky, but I couldn't come up with a more elegant solution that operated=
 in
> a similar vein to how python feels as a language.

Part of how Python feels as a language is due to the fact that
stateful operations cannot, in general, be expressed cleanly as
expressions - you have to step up to a multi-statement procedural
algorithm if your state can't be expressed cleanly through simple
iteration.

I and others have put forward various proposals to change this over
the years, but it's a complex problem that touches on the heart of the
statement/expression dichotomy that Guido deliberately introduced when
creating the language.

The mechanism I personally consider most promising is one that makes
it easier to be explicit that a particular function is only used in
the current statement (see PEP 403). It still feels like Python (i.e.
no embedded assignments), but also clearly expresses when a function
exists solely for code structure purposes, and has nothing to do with
splitting out a component that will be used from multiple locations.

The current design proposal in PEP 403 is still quite flawed, though,
and needs a substantial amount of work to be brought up to a standard
where it makes a compelling case for a change to Python.

Cheers,
Nick.

-- =

Nick Coghlan=A0=A0 |=A0=A0 ncoghlan@gmail.com=A0=A0 |=A0=A0 Brisbane, Austr=
alia
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
http://mail.python.org/mailman/listinfo/python-ideas
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic