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. > > > I think in most cases what's on the right side will be something that's not > assignable. Likewise with the proposal to use => for lambda, someone could > read (a => a + 1) as putting a into a + 1. I think they're going to get over > that. > > 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 > > APL uses a tacit syntax while Ruby and SmallTalk use explicit syntaxes. The > equivalent of x => x + 1 in each of these is > > APL ⍺+1 (I think) > Ruby |x| x + 1 > SmallTalk [ :x | x + 1 ] >
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. ChrisA _______________________________________________ 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/WFOWBIFZZ3ICJLRIMQTX6K2NDXYVQMNV/ Code of Conduct: http://python.org/psf/codeofconduct/