On Tue, Oct 26, 2021 at 08:59:51AM +0100, Rob Cliffe via Python-ideas wrote:

> And I don't understand what point you're making here.  Yes, the walrus 
> operator can appear in various places, how is that relevant? You could write
>     def f(a := (b := c)):
> which might be a tad confusing but would be unambiguous and legal, just as
>     def f(a = (b := c)):
> is currently legal (I tested it).  I don't see a clash.

If we have a choice between a dozen syntax variants that are not 
confusing, and one which is confusing, why would we prefer to pick the 
one that is confusing over any of the others?


> Perhaps I wasn't clear.  When I said 'inefficiency', I meant to refer to 
> cases like
>     def f(a := b+1, b := e+1, c := a+1, d := 42, e := d+1)
> where late-binding defaults are allowed to refer to subsequent 
> arguments.  Here Python has to work out to assign first to d, then e, 
> then b, then a, and finally c, which AFAICS requires multiple passes. 

No, I don't think we need to do anything that intricate. It is not the 
responsibility of the interpreter to **make it work** no matter what, 
any more than we expect the interpreter to make this work:

    a = b + 1
    b = e + 1
    c = a + 1
    d = 42    #  <<<<<-----start here
    e = d + 1

It is enough to have a simple rule:

- bind early bound defaults left to right first;
- bind late bound defaults left to right next.

(That's my preference.) Even simpler would be a strictly left-to-right 
single pass but that would be, I think, too simple. YMMV. I'm not 
prepared to fight to the death over that one :-)


-- 
Steve
_______________________________________________
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/QH4IRAPKOW333P4QLVVQM2PQ32TVL33T/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to