WAT: opCmp and opEquals woes

Iain Buclaw via Digitalmars-d digitalmars-d at puremagic.com
Mon Jul 28 05:57:33 PDT 2014


On 26 July 2014 00:31, Walter Bright via Digitalmars-d
<digitalmars-d at puremagic.com> wrote:
> On 7/25/2014 4:28 PM, H. S. Teoh via Digitalmars-d wrote:
>>
>> That page doesn't say anything about TypeInfo, though.
>
>
> It says to follow the form.
>
>
>> But even then,
>> why doesn't the compiler reject opCmp signatures that don't match the
>> compiler's expectations?
>
>
> Because you may want to use an opCmp for other purposes.
>

I think this is bad practice.  I did write a terse API for a library
I'm building up, where:

return a < b;

Would return codegen describing the operation of (a < b).

I had second thoughts about it though, mostly because it was perhaps a
bit *too* magical. :)

Iain


More information about the Digitalmars-d mailing list