[OT] Perl woes

Nicholas Clark nick at ccl4.org
Wed Jan 28 11:58:40 GMT 2009


On Wed, Jan 28, 2009 at 11:31:37AM +0000, Dominic Thoreau wrote:

> Eg string concatenation in perl is with the . (dot) operator. In some
> other well used languages (Java, for example) the + operator is used,
> which is an overloading of the addition operator.

> I'm taking a series of courses in Java (don't shun me for this - it's
> part of my OU degree), and I did comment the grumble to the tutor that
> it won't let you overload these operators yourself for your own
> objects (like, say, C++ will). His comment was that it was a trade
> off, sacrificing power in the hope that responsibility was also
> lessened, but I'm not sure it was a good design decision.

So, "do as I say, not as I do".

The language designers felt that overloading was the best solution to one
of their problems, but then denied it to the lesser mortals who are mere
users.

(Note that Java can do overloading of a single operator to perform addition
or concatenation, because it has compile time types, and so can
disambiguate which one is needed.

Whereas in dynamic languages, a variable doesn't know its type at run time, so
you need two operators to ensure deterministic behaviour and sanity.)

Nicholas Clark


More information about the london.pm mailing list