while (a=b()) ...

Jim Meier fatjim at home.com
Sat May 15 13:28:37 EDT 1999


Fredrik Lundh wrote:

> Aahz Maruch <aahz at netcom.com> wrote:
> > What does this give you that
> >
> >   for line in f.readline()
> >     frobulate(line)
> >
> > does not?  (Assuming the necessary semantic changes to permit this to
> > work *well*.)

As was told to me previously, this *is* excellent, readable and usable..
But while it does solve the big, big "while 1"-is-not-an-infinite-loop
ugliness, the use of break is still involved instead of other, harder-edged
controls. I have no problem with this, I just felt like nit-picking to
recover my manliness. <whoops-blew-my-cover-style grin>

>
> I find it quite hard to figure out how "for-in"
> would be changed to work as you expect.
> you could of course change f.readline to
> return an iterator, but that would break
> tons of code...
>
> </F>

Well, we could always tack on a calling context argument (wow, a language
with explicit context - I've wanted that in real life (for the news,
scientific results, DATING, etc..) for YEARS!) to functions called.

For example,

>>> f.readline()
context = INTERPRETER, STRAIGHT_CALL, ARGS_0 (line number, calling module
stack, etc?)

>>> a=f.readline()
context = above context plus ASSIGN_TO

>>> for line in f.readline():
...    shananna(line)
context(for readline) = INTERPRETER, FOR_LOOP,  etc.

etc...

Optional automatic resolution of a particular function to call (rather than
deciding in readline itself, then branching) would be nice..

Jim proposes a new thread, based mostly on the transactions he's been
interested in lately: neatest modifications, ideas, etc for the language
itself. This group seems very fertile with intelligent, creative people
with good critical abilities.


the-interpreter-should-choke-on-uninformative-variable-names-ly yours, Jim.

(Or am I not allow to use that idom until the mentor taps me with the wand?
:)






More information about the Python-list mailing list