A Fresh Look at Comparisons, Take 2

Janice Caron caron800 at googlemail.com
Fri Apr 18 23:13:26 PDT 2008


On 19/04/2008, Bill Baxter <dnewsgroup at billbaxter.com> wrote:
>  Not many people are going to read a big long thread to try to piece
> together what the proposal actually is.  Especially the one person who
> really matters here, Walter.

I get that, but the trouble is, even /I/ don't think it's a great idea
at this stage, despite the fact that I suggested it. Partly, that's
because it's ugly. You have to admit that

    struct S
    {
        explicit bool opEquals(explicit ref const(S) s) const {...}
        explicit int opCmp(explicit ref const(S) s) const {...}
    }

is not terrifically "friendly" looking. But the /main/ thing that
concerns me is that two posters have pointed out that static-typing
isn't good enough. That means, you need run-time typing, and that, in
turn, means you need double-dispatch (or multimethods), which in turn
means it just plain won't work with the suggested syntax.

The simplest workarounds are, in fact /current D/. The simplest
workaround for inheritance is to supply a function which throws an
exception; the simplest workaround for double-dispatch is to accept an
Object parameter and do all the tests at run-time.

The things that people /really/ care about (e.g. that opEquals should
return bool, that opEquals and opCmp should be const) have already
been complained about in bugzilla.

In summary, enough objections to the other stuff have been brought up
on this thread to make me think it's not workable. At least, not yet.
In order to be workable, we must first solve (1) annotations, and (2)
multiple dispatch. And those are separate subjects.


> So if you think it's a super idea then you
> should write it up in a condensed format.

Of course. But I don't any more, and I wouldn't have learned that if
we hadn't discussed it here first.



More information about the Digitalmars-d mailing list