syntax for preset locals without using dummy args with defaults
Beni Cherniavsky
cben at techunix.technion.ac.il
Mon Jan 13 11:47:21 EST 2003
On 2003-01-13, Beni Cherniavsky wrote:
> 2. I see no elegant syntax to allow multiple bindings on the same level
> (e.g. let and not "poor-man's let*"). For multiple bindings that
> are not inter-dependent, nesting the lets is visually sub-optimal...
> The closest thing in python for simultatneous bindings is augmented
> assignment but it was not designed for this case (no var-value pairs
> ordering and doesn't continue for many lines).
>
Sorry, by "augmented assignments" I meant tuple assignments, like:
a, b = foo(), bar()
> > I think if it became a convention to set up bindings to module elements
> > etc, and do other expensive one-time things in the preset: suite, we would
> > see both less clutter in the function code body and better speed.
> >
>
What I forgot to say here is that from my lisp/scheme experince, I was
doing "manual common subexpression elimination" all around, binding almost
every thing that appeared at least twice with let. It really felt as
a very elegant and readable way to code.
I'm frequently coding in Python in a similar way, making lot's of little
assignments. I feel some guilt for polluting the namespace :-). I figure
that a let statement would be very handy for me. Sure, I will abuse it
for closures :-).
> > Conceivably on could write a source-transforming optimizer to hoist builtin
> > dotted module references into the preset suite, as a start. Maybe with
> > some hints it could hoist other global refsas well. It might be an
> > alternative to complex runtime global access optimizations.
> >
> They are not that complex, especially PEP 267. If the only use for this
> is proving clean syntax for manual optimization of global lookups, I'm
> against it. I do think that a let construct could be very useful beyond
> optimizations, as I said above.
>
Here I refered to the part I forgot ;-)
--
Beni Cherniavsky <cben at tx.technion.ac.il>
Holy resolution for a holy war: the Torah stores most numbers as
little-endian (e.g. "seven and twenty and a hundred years")!
More information about the Python-list
mailing list