Short list with things to finish for D2
Andrei Alexandrescu
SeeWebsiteForEmail at erdani.org
Thu Nov 19 00:09:02 PST 2009
Gzp wrote:
> bearophile wrote:
>> Andrei Alexandrescu:
>>
>>> * Encode operators by compile-time strings. For example, instead of
>>> the plethora of opAdd, opMul, ..., we'd have this:
>>>
>>> T opBinary(string op)(T rhs) { ... }
>>>
>>> The string is "+", "*", etc.
>>
>> Can you show an example of defining an operator, like a minus, with that?
>>
>> In my set data structure I'd like to define "<=" among two sets as "is
>> subset". Can that design allow me to overload just <= and >= ? (opCmp
>> is not enough here).
>>
>> Bye,
>> bearophile
>
> And what about the unary operators. Sorry I was not following the
> opBinary thread from the beginning, so it might have been discussed
> before. If opBinary has a syntax like this, unary operators require
> something like this at least just for completeness.
Yes; opBinary was just given as an example. Unary operators look like this:
T opUnary(string op)();
> (And maybe trinary operators ?: ) :)
> Can they still be overloaded ? Will they have a similar syntax ? If so
> what about the e++ and ++e operators? How they are distinct ? Or is the
> latter eliminated from the language ?
> Though, I like the idea, just a quick look at a code and you can see all
> the operators in a place.
>
> Bye, Gzp
I think user code should only define ++e. Then the compiler can use that
to define e++.
Andrei
More information about the Digitalmars-d
mailing list