I said I'd drop the discussion about lambda, but this
isn't really the same discussion even if it is part of
the same thread. That's my excuse, and I'm sticking to it.
Terry said:
I understand that the backslash is popular in some ivory-tower functional
languages. Currently, a backslash can be used for explicit line joining,
and is illegal elsewhere on a line outside a string literal, so i think
it's available for this. It would be utterly unpythonic to use puntuation
instead of a keyword, and it would make no sense to novices, but it would
scare the crap out of C programmers, which has to be worth something.
With list comprehensions and generators becoming so integral, I'm
not sure about "unpythonic". And a syntax just occured to me --
what about this:
[y*x for x,y]
?
(that is:
[<expression> for <argument list>]
It's just like the beginning of a list comprehension or generator, but
without the iterator. That implies that one must be given, and
the result is therefore a callable object.
That is a very long chain of implication:
"It looks like a list comprehension... but there is no
iterator... so we have to supply an iterator... so it
takes an argument... so it is a callable object... oh
and by the way, it can take any arguments, not just
iterators."
It is also far too easy to make a mistake, eg to write
something like newlist = [y*x for x,y] when you
actually wanted the list comp [y*x for x,y in L].
This would create an anonymous function where you
expected to create a list. It is hard to think of a
usage case where you didn't discover the error
reasonably soon, but it would be better for leaving the
iterator out of a list comp to remain a syntax error,
rather than produce an unexpected, but legal, object.
Besides, I think Guido should be very cautious about
introducing new features that use punctuation, instead
of keywords. We don't want to become perl do we?