Overloading relational operators separately; thoughts?

Russel Winder via Digitalmars-d digitalmars-d at puremagic.com
Thu Sep 29 05:20:42 PDT 2016


On Thu, 2016-09-29 at 11:50 +0000, Minty Fresh via Digitalmars-d wrote:
> On Thursday, 29 September 2016 at 11:29:55 UTC, Russel Winder 
> wrote:
> > 
> > However, this has come up many times, and every time Walter 
> > says "no, it's wrong". Whilst the C++ iostreams << may have 
> > problems, using this as a single point argument as to why 
> > overloading fails in all other cases except numeric arithmetic 
> > is bad philosophy. In my view this is holding D back.
> 
> To add some thoughts to this,
> 
> The use of << being bad is purely a matter of opinion.
> If you believe that << is to only be used for bit-shifting 
> operations, you might hold the view that it is bad.

But, but, but, << means very much less than, everyone knows this. What
is this bitshifting of which you speak.

!

> On the other hand, if you come from a background like Haskell or 
> Ruby, you might have a very different opinion.

Is there anyone from an Haskell background here. :-) Anyway everyone
who wants to make Haskell code mainstream is using Frege.

> ie.
> In Ruby, << is named the shovel operator. It's uses are things 
> like appending an element into an Array.

Groovy, and indeed Python, likewise. We ignore the mess Algol68 and
Scala have got themselves into with this.

> 
> Hence, a less opinionated point is necessary here.

Opinionated is not always bad. Look at Go, the developers know that
there is no sane way of doing generics so they ban it. Also they know
that exceptions are totally incomprehensible to all programmers so they
ban them. Rust developers know that all memory handling must be
explicit all the world falls apart. Opinionated languages clearly get
traction – not usually because of the opinions, it has to be said, more
usually because of the amount of money thrown at marketing. Except
Python, obviously.

-- 
Russel.
=============================================================================
Dr Russel Winder      t: +44 20 7585 2200   voip: sip:russel.winder at ekiga.net
41 Buckmaster Road    m: +44 7770 465 077   xmpp: russel at winder.org.uk
London SW11 1EN, UK   w: www.russel.org.uk  skype: russel_winder
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: This is a digitally signed message part
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20160929/f6fc3380/attachment.sig>


More information about the Digitalmars-d mailing list