On Fri, Apr 17, 2020 at 03:46:31AM -0000, [email protected] wrote:
> @Steven D'Aprano see that it doesn't actually have to look like a
> pair, it doesn't need to be one at all. Just like in:
> ```python
> def f(a):
> ...
> f(x)
> ```
>
> `x` is implicitly assigned with `a`
We're not talking about positional arguments here. If you want to
include positional arguments in the analysis, then we already have a
perfectly good way to write function calls without repeating outselves:
# Instead of this:
function(spam=spam, eggs=eggs, cheese=cheese)
# Just do this:
function(spam, eggs, cheese)
And we're done, the problem is solved, and no new syntax is needed.
But using positional arguments misses the point that, for many purposes,
keyword arguments have advantages and we want to use them. Using
positional syntax may be either undesirable or not possible.
So my comment needs to be read with the understanding that we are
specifically talking about keyword, not positional, syntax. And in
keyword syntax, we need a name=value pair.
At least your suggested syntax gives a strong clue that we are dealing
with a name=value pair: `name=`.
Whereas the Javascript and Rust syntax gives us *no* visual clue at all
that we're dealing with a name=value pair, it looks like values are
assigned by position: `name`. I think this is bad.
Consider a function `def func(spam, eggs)`, and consider the
function call `func(eggs, spam)`. It makes a big difference whether the
values are assigned using positional rules:
eggs --> parameter 0, "spam"
spam --> parameter 1, "eggs"
or keyword rules:
# func(eggs, spam) is shortcut for eggs=eggs, spam=spam.
eggs --> parameter "eggs"
spam --> parameter "spam"
Anyway, I realise that you are not proposing the Javascript/Rust style
syntax, so we can move on :-)
--
Steven
_______________________________________________
Python-ideas mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at
https://mail.python.org/archives/list/[email protected]/message/NNL2M2UV7FG7QAMTGOWTNJRDBUPZAXYC/
Code of Conduct: http://python.org/psf/codeofconduct/