On Mon, Feb 15, 2021 at 12:02 PM Ricky Teachey <ri...@teachey.org> wrote:

> On Mon, Feb 15, 2021, 11:34 AM David Mertz <me...@gnosis.cx> wrote:
>
>> On Mon, Feb 15, 2021 at 4:19 PM Guido van Rossum <gu...@python.org>
>> wrote:
>>
>>> Okay, here’s my dilemma. It looks like this thread wants to devise a new
>>> syntax for lambda, using e.g. (x, y) -> x+y, or the same with =>. That’s
>>> great, but doesn’t open new vistas. OTOH, for people using type
>>> annotations, a much more pressing issue is an alternative for
>>> typing.Callable that is more readable, and supports extra features that
>>> Callable doesn’t, like keyword args, varargs, and pos-only.
>>>
>>
>> FWIW, I *do not* want an alternate spelling for lambda.
>>
>> If your time machine were still working, and you could go back to 1991 to
>> change the spelling, yes I might like that.  For that matter, if someone
>> had a good spelling for multi-line lambdas, I might like that.  Or *maybe*
>> some other difference in behavior, but nothing comes immediately to mind.
>>
>> But allowing a few cryptic punctuation symbols to express an anonymous
>> function while still retaining "the name of a cryptic greek letter" to do
>> exactly the same thing seems like a strong non-goal.
>>
>> That said, if I had to look at one, I'd like '->' much better than '=>'.
>>
>
> I also don't see this as a very worthwhile goal.
>
> But if we could expand the  proposal to allow both anonymous and named
> functions, that would seem like a fantastic idea to me.
>
> Anonymous function syntax:
>
> (x,y)->x+y
>
> Named function syntax:
>
> f(x,y)->x+y
>
> But since Guido wants to save the right shaft operator for type hinting,
> and named functions do need a way to write type hints, maybe the best thing
> to do is use an equal sign shaft for the function definition and the right
> shaft for the type hint:
>
> f(x,y)=>x,y->str
>
> >>> f('a','b')
> 'ab'
> >>> f(1,2)  # type hint error
>
> Rick.
>

Sorry I was typing that last one on my phone and typed a mistake. Should
have been a plus sign in the expression and not a comma:

f(x,y)=>x+y->str

>>> f('a','b')
'ab'
>>> f(1,2)  # type hint error

---
Ricky.

"I've never met a Kentucky man who wasn't either thinking about going home
or actually going home." - Happy Chandler
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/MYNTQSLTFOIHA44KU6Q4UIZ3OD42JRLM/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to