Oh look, another language (ceylon)

Rick Johnson rantingrickjohnson at gmail.com
Mon Nov 18 22:33:01 EST 2013


I've never *really* been crazy about the plus operator
concatenating strings anyhow, however, the semantics of "+"
seem to navigate the "perilous waters of intuition" far
better than "*".

    Addition of numeric types is well defined in maths:
    Take N inputs values and *reduce* them into a single
    value that represents the mathematical summation of
    all inputs.
        
    HOWEVER, 
    
    Addition of strings (concatenation) requires
    interpreting the statement as a more simplistic
    "joining" process of : take N inputs and join them
    together in a *linear fashion* until they become a
    single value.
    
As you might already know the latter is a far less elegant
process, although the transformation remains "sane". Even
though in the first case: with "numeric addition", the
individual inputs are *sacrificed* to the god of maths; and
in the second case: for "string addition", the individual
inputs are *retained*; BOTH implementations of the plus
operator expose a CONSISTENT interface -- and like any good
interface the dirty details are hidden from the caller!

    INTERFACES ARE THE KEY TO CODE INTEGRITY and LONGEVITY!

HOWEVER, HOWEVER. O:-)

There is an inconsistency when applying the "*" operator
between numerics and strings. In the case of numerics the
rules are widely understood and quite logical, HOWEVER, in
the case of "string products", not only are rules missing,
any attempt to create a rule is illogical, AND, we've broken
the consistency of the "*" interface!

    py> "a" * "4"
    'aaaa'
    
Okay, that makes sense, but what about:

    py> "a" * "aaaa"

That will haunt your nightmares!

But even the previous example, whilst quite logical, is
violating the "contract of transformations" and can ONLY
result in subtle bugs, language designer woes, and endless
threads on Pyhon-ideas that result in no elegant solution.

    THERE EXISTS NO PATH TO ELEGANCE VIA GLUTTONY

Operator overloading must be restricted. Same goes for
syntactic sugars. You can only do SO much with a sugar
before it mutates into a salt.

    TOO MUCH OF A GOOD THING... well, ya know!



More information about the Python-list mailing list