Oh look, another language (ceylon)

Chris Angelico rosuav at gmail.com
Mon Nov 18 01:56:33 EST 2013


On Mon, Nov 18, 2013 at 5:45 PM, Gregory Ewing
<greg.ewing at canterbury.ac.nz> wrote:
> Rick Johnson wrote:
>>
>>     The multiplication operator can ONLY be used on
>>     numerics.
>
>
> I'm not convinced about that part. I notice that
> subtraction, multiplication and division are bundled
> into a single interface Numeric, but there is a
> separate one called Summable for addition --
> apparently so that they could use + for string
> concatenation.
>
> This seems to be a case of one rule for the language
> designers and a different one for everyone else.
> If it's okay for '+' to be used on something that's
> not a number, why not '*'?

That's something Java did (using + for strings, but not supporting
operator overloading for custom classes, so you can't make your own
string-like or number-like class and use + with it), and IMO it's one
of the language's annoying flaws. Give people the power to use
whatever operator they choose in whatever way they choose, and accept
that occasionally you'll get less-than-stellar usage. It's a cost that
you pay happily when you let people name their own functions; why not
give the same freedom for operators?

ChrisA



More information about the Python-list mailing list