--- Bruce
On Sat, Oct 23, 2021 at 7:55 PM Chris Angelico <ros...@gmail.com> wrote: > On Sun, Oct 24, 2021 at 1:48 PM Bruce Leban <br...@leban.us> wrote: > > > > > > On Sat, Oct 23, 2021 at 6:23 PM Jelle Zijlstra <jelle.zijls...@gmail.com> > wrote: > >> > >> In the PEP's example: > >> > >> def bisect_right(a, x, lo=0, hi=>len(a), *, key=None): > >> > >> This reads to me like we're putting "hi" into "len(a)", when it's in > fact the reverse. > > > > Every language I am aware of that has adopted a short hand lambda > notation (without a keyword) has used => or -> except APL, Ruby, SmallTalk. > See https://en.wikipedia.org/wiki/Anonymous_function > > > Anonymous functions are an awkward parallel here. The notation you're > describing will create a function which accepts one argument, and then > returns a value calculated from that argument. We're actually doing > the opposite: hi is being set to len(a), it's not that len(a) is being > calculated from hi. > > That said, though, I still count "=>" among my top three preferences > (along with "=:" and "?="), and flipping the arrow to "<=" is too > confusable with the less-eq operator. > Sorry I was less than clear. The syllogism here is (1) late-evaluated argument default should use => because that's the proposal for shorthand lambda (2) shorthand lambda should use => because that's what other languages use. I was talking about (2) but I should have been explicit. And yes, you highlight a potential source of confusion. def f(x=>x + 1): ... means that x is 1 more than the value of x from the enclosing global scope (at function call time) while g = x => x + 1 sets g to a single-argument function that adds 1 to its argument value. --- Bruce
_______________________________________________ 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/4X2ESYS4OK6HSPKTPCUP742NS2XJUZT4/ Code of Conduct: http://python.org/psf/codeofconduct/