Brython - Python in the browser

Chris Angelico rosuav at gmail.com
Sat Dec 22 22:49:31 CET 2012


On Sun, Dec 23, 2012 at 7:31 AM, Dan Sommers <dan at tombstonezero.net> wrote:
> On Sat, 22 Dec 2012 23:11:00 +1100, Chris Angelico wrote:
>
>> "This is a string" / 3 ==> ["This ", "is a ", "strin", "g"]
>> and "This is a string" // 3 ==> ["This ", "is a ", "strin"]
>> then "This is a string" % 3 ==> ["g"] or possibly "g"
>>
>> which is incompatible with current usage. But that's a meaning that
>> makes reasonable sense as "modulo".
>
> So why are we all so comfortable with using "*" as the operator for
> multiplication?  I'm sure that a new programming language that dared to
> use U+00D7 or U+2715 for multiplication would be instantly rejected on
> the grounds that it was confusing and incompatible with current practice.

Less on the confusing and more on the hard to type; same reason we
don't indicate division by writing a long bar, but use the slash
instead. Also, algebra has a tendency toward short variable names,
where programming tends toward longer ones, so algebra optimizes in
favour of multiplication - that's why we don't write code like
"h{ello}w{orld}" to mean "multiply hello by world".

> Until recently, the number of characters available to a programming
> language was limited (APL notwithstanding).

REXX had two boolean negation operators, one of which wasn't ASCII.

> Practicality beat (paste tense) purity.

Yep. Definitely. We need to be able to type code fast, read code fast,
and worry about algebra slowly. Arguments from algebra are mainly for
justifying a new piece of syntax so people can understand it without
having to keep the manual open beside them.

ChrisA



More information about the Python-list mailing list