evhub / coconut

Simple, elegant, Pythonic functional programming.
http://coconut-lang.org
Apache License 2.0
4.05k stars 120 forks source link

Lambdas should use fat arrows #763

Closed evhub closed 1 year ago

evhub commented 1 year ago

Coconut's x -> x lambda syntax was created before Python introduced the use of -> for return type annotations. Now that Python uses -> for return type annotations, using -> for lambdas is confusing--and even creates some syntactic problems, e.g. supporting return type annotations for statement lambdas.

Though we'll probably never remove support for -> lambdas, since they've been a part of the language for so long, it might make sense to deprecate them and try to move over to => lambdas instead.

evhub commented 1 year ago

If we do this, we should probably not allow fat arrows for typing.Callable type definition syntax (e.g. we should stick with f: int -> int and not allow f: int => int).

evhub commented 1 year ago

Since this is so ingrained in the language, we'll probably have -> lambdas pass silently without --strict and only even show a warning with --strict. Raising an error for this on --strict or showing a warning on non---strict is probably too much here, likely for quite some time. We can change all the documentation, though, to suggest => over ->.

evhub commented 1 year ago

Docs are now updated for this, but the website still needs to be updated once this is live.

Edit: Actually, maybe leave the website as is until the interpreter on it is updated.