Overloading relational operators separately; thoughts?

Jonathan M Davis via Digitalmars-d digitalmars-d at puremagic.com
Thu Sep 29 11:38:42 PDT 2016


On Thursday, September 29, 2016 18:14:22 Minty Fresh via Digitalmars-d wrote:
> On Thursday, 29 September 2016 at 18:07:37 UTC, Russel Winder
>
> wrote:
> > On Thu, 2016-09-29 at 10:52 -0700, Walter Bright via
> >
> > Digitalmars-d wrote:
> >> On 9/29/2016 9:41 AM, Sai wrote:
> >> > If I understand the issue correctly, one will not be able to
> >> > overload <=, >, etc
> >> > for symbolic math, like CAS (mimicking mathematica for
> >> > example),
> >> > how can I do it
> >> > now?
> >>
> >>     a.isLessThan(b)
> >
> > How wonderfully Java.
>
> Personally, I'm amused because this implies the prospect of:
>
>    a.isGreaterThanOrEqualTo(b)
>
> I mean, there is an acceptable level of verbosity. This is not it.

Then you could always do something like a.myOp!"<"(b) and a.myOp!">="(b) if
you still want to have the operator in there somewhere. You can name the
functions whatever you want. You just can't use overloaded operators for it,
since it would not be in line with what the operators are supposed to mean
and be used for.

- Jonathan M Davis



More information about the Digitalmars-d mailing list