On 24 April 2018 at 22:30, David Mertz <me...@gnosis.cx> wrote: > I do think the pronunciation issue that Greg notices is important. I teach > Python for most of my living, and reading and discussing code segments is an > important part of that. When focussing on how Python actually *spells* > something, you can't always jump to the higher-level meaning of a construct. > For some complex expression—whether or not "binding expressions" are > added—sometimes it makes sense to give a characterization of the *meaning* > of the expression, but other times you want to say aloud the entire spelling > of the expression. > > Although feelings are mixed about this, I like the "dunder" contraction for > this purpose. It's less of a mouthful to say "dunder-init" than > "underscore-underscore-init-underscore-underscore" aloud. And once you > learn that shorthand, it's unambiguous. > > I think I'd pronounce: > > if (diff := x - x_base) and (g := gcd(diff, n)) > 1: > return g > > As: > > "If diff bound to x minus x_base (is non-zero), and g bound to gcd of diff > comma n is greater than 1, return g"
Pronouncing it as "name bound to expr" would also fit well with calling the overall construct a binding expression. You could also postpone the definitions to the end when speaking aloud: "if diff is true and g is greater than 1, then return g, given that diff is bound to ex minus ex-base and g is bound to the gcd of diff and n" However, that long form sounded awkward to me, though, so I ended up wanting to rephrase it as just: "if diff is true and g is greater than 1, then return g, given that diff is ex minus ex-base and g is the gcd of diff and n" (The only change is to replace both occurrences of "is bound to" with a simple "is") And writing that out actually gave me an idea that I don't believe has come up before (or if it did, it got lost somewhere in the depths of a long python-ideas thread): if (diff is= x - x_base) and (g is= gcd(diff, n)) > 1: return g With the mnemonic for what the binding expression means being the following invariant: _rhs = expr assert (name is= _rhs) is _rhs and name is _rhs In a very real sense, that's *exactly* recreating the C pointer semantics for "==" ("check if two pointers reference the same object") vs "=" ("make two pointers reference the same object"), we'd just be spelling it as "is" vs "is=". Given that spelling, a reasonable inline pronunciation of "is=" would still be Davids suggestion of "is bound to": "if diff is bound to ex minux ex-base and is true and g is bound to the gcd of diff and n and is greater than 1, then return g" Simplifying "is bound to" to "is" in the post-definition form would just be a verbal shorthand. Cheers, Nick. -- Nick Coghlan | ncogh...@gmail.com | Brisbane, Australia _______________________________________________ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com