PEP 312 - Making lambdas implicit worries me, surely it's just the name 'lambda' that is bad...

Sean Ross sross at connectmail.carleton.ca
Mon Mar 3 10:08:46 EST 2003


"Roman Suzi" <rnd at onego.ru> wrote in message
news:mailman.1046677684.8629.python-list at python.org...
> On Sun, 2 Mar 2003, Sean Ross wrote:
>
> > How about "do", instead of "fn"?:
>
> As on of the PEP 312 authors, I must explain. PEP 312 is not about adding
> new keywords, etc.
>

Yes. I was aware of that when I made my post. PEP312 is about removing
keywords, or,
more precisely, making them
    "optional in some cases where it is not grammatically ambiguous"
I was not suggesting otherwise. I was suggesting "do" over "fn".  Someone
suggestion "fn". I didn't care for that, so I suggested "do", mostly because
it was not an abbreviation but also because it has been used in Ruby to
delimit blocks.
 Nothing more than that - idle speculation, what if's, that sort of
thing...i.e.,
    If you were going to change the keyword lambda(and not make it
optionally implicit), then I think "do"
    would be a better replacement than "fn".

>And I am already allergic (thanks PEP 308) to such
> suggestions.

I rather enjoyed reading the PEP308 debate. I find the idea of language
design to be very interesting
and I found the discussions and differences of opinions over a single
feature fascinating. Perhaps if I
had to implement this language,  I would be more concerned by idle
speculations that include keyword
introductions but, for the moment, I'll just enjoy playing with the syntax
to see if there is a better way.
Or, at least, a way that I'd prefer were I to implement a language. In
general, this is my point of view when
I post syntax alteration ideas.  I'm just trying them out. Seeing if one way
is better than another, or more
preferred. If they were more than that, I should write a PEP. (or a
language)

>The only problem with PEP 312 as I see it is that lambdas are
> more useful when they have arguments. And this is hard to help without
> "lambda" keyword.
>

Our opinion differ slightly here. Personally, I have no problem with
"lambda", but I can see where it could be intimidating.
And, given my preference, I would have chosen "do", but we won't go there at
the moment
IMO, the problems with PEP 312 are twofold: (1) it favors implicit over
explicit and (2) it introduces inconsistent syntax -
two possible lambda forms without arguments, and one form with arguments.  I
could argue that my objection to (1) is not strictly correct, since, in the
new form ":expression", the colon, in certain unambiguous cases, and once we
have learned the new idiom, explicitly signifies that we are dealing with an
anonymous function. I don't find that it's level of "explicitness" matches
my taste but, either way, (1) does not concern me greatly in this particular
case. (None of them "concern me greatly", but it's a nice turn of phrase...
moving on...)
However, if you prefer consistent syntax, which I do, then I should think
that (2) would be of more concern. Of course, the new syntax is optional, so
if consistency is your bugaboo, you can still use the "lambda" for
argumentless anonymous functions, if you want to, but others may not, and
you'll have to remain aware of each form.

Anyway, all if this is just to say, I saw a post suggesting "fn" and
thought, "Well, 'do' is not 'lambda', it's less intimidating, it's shorter,
it's been used in other languages, it can be used explicitly and
consistently, it's not 'fn', and it's not abbreviated, I think I'll fly that
idea out there, what the hey. It's not like anyone's going to rush out and
add it to the language..."


speculatively-yrs
Sean






More information about the Python-list mailing list