[Python-ideas] A "local" pseudo-function
Robert Vanden Eynde
robertvandeneynde at hotmail.com
Sun Apr 29 22:14:17 EDT 2018
I really liked the syntax that mimicked lambda even if I find it verbose :
a = local x=1, y=2: x + y + 3
Even if I still prefer the postfix syntax :
a = x + 3 where x = 2
About scheme "let" vs "let*", the paralel in Python is :
a, b, c = 5, a+1, 2 # let syntax
a = 5; b = a+1; c = 2 # let* syntax
Which makes be wonder, we could use the semicolon in the syntax ?
a = local x = 1; y = x+1: x + y + 3
Or with the postfix syntax :
a = x + y + 3 where x = 1; y = x+1
Chaining where would be is syntax error :
a = x + y + 3 where x = 1 where y = x+1
Parenthesis could be mandatory if one wants to use tuple assignment :
a = local (x, y) = 1, 2: x + y + 3
When I see that, I really want to call it "def"
a = def (x, y) = 1, 2: x + y + 3
a = def x = 1; y = 2: x + y + 3
Which is read define x = 1 then y = 2 in x + y + 3
Using def would be obvious this is not a function call.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20180430/f16c05f6/attachment.html>
More information about the Python-ideas
mailing list