Overloading relational operators separately; thoughts?

Jonathan M Davis via Digitalmars-d digitalmars-d at puremagic.com
Thu Sep 29 17:50:54 PDT 2016


On Thursday, September 29, 2016 22:37:51 Minty Fresh via Digitalmars-d wrote:
> On Thursday, 29 September 2016 at 22:27:50 UTC, bachmeier wrote:
> > You're looking for https://www.perl.org/ That's a highly viable
> > language, where you can do things like bury $[ = 1 somewhere in
> > your code to change from 0-indexing to 1-indexing of arrays.
> > They take pride in unpredictable, unreadable code.
>
> This is not at all relevant to the current argument.

Except that it kind of is. It's an example of a language allowing you to
mess with too much and make it so that it doesn't function as expected,
which is what happens when you overload operators to act in a way
inconsistent with how they work with the built-in types. The perl example is
more extreme, but the point still stands that having normal, common
constructs operate in a way that's inconsistent with how they normally work
tends to make code harder to read and maintain. Certainly, it can result in
very unexpected behavior when mixing it with generic code that uses those
operations.

- Jonathan M Davis



More information about the Digitalmars-d mailing list