Some notes

Alex Martelli aleaxit at yahoo.com
Thu Oct 14 03:42:25 EDT 2004


Josiah Carlson <jcarlson at uci.edu> wrote:
   ...
> > - TABs can be accepted only inside comments.
> 
> In Py3k, tabs are not going to be allowed as indentation to Python code.
> Keeping them in strings and comments is a non-issue.

While it ain't a biggie, I'd like to see tabs forbidden in string
literals -- using \t when you mean tab is more readable, and the one
obvious way to do it.

> > - The optional static typing seems a quite nice thing (for compilers
> > too, they can produce faster code. It can probably allow faster and
> > smaller arrays, like those of numarray).
> 
> Asking for static typing in Python is a pretty big request.  It seems
> from those responses to similar questions, the answer is simply "static
> typing isn't coming to CPython any time soon, probably not even for Py3k".

Unfortunately I suspect you may be wrong (for py3000 only): GvR does
seem to like the idea of optional static typing (perhaps with
interfaces, only, not necessarily with _types_ as such).

> > - The functional IF seems interesting, like:
> > if(cond, code1, code2)
> > (Or maybe a different syntax, that allows elseif too.)
> 
> Many variants have been proposed over the years, but none have ever made
> it in.

I think generators could get us close to this kind of thing (in Py3k).

They'd have to sprout a new method 'skip', similar to 'next' but defined
to not evaluate the argument of the next yield.  Then, for some form of
function call, foo(a, b, c), instead of the current equivalent-of
    _temp = a, b, c    # make args tuple (evaluating all args)
    foo(*_temp)        # pass the tuple to foo
would compile to the equivalent of
    def _temp():
        yield a
        yield b
        yield c
    foo(@_temp)        # fantasy syntax for 'pass the generator to foo'

We could use braces instead of parentheses for this hypothetical
__call_with_generator__, whatever.  Such functions as lisp's cond might
then easily be implemented:

def cond(@_args):
    for test in _args:
        if test: return _args.next()
        else: _args.skip()

Just musing, of course, but it does appear within reach, while, before
generators, it didn't.


Alex



More information about the Python-list mailing list