opStarAssign?

Robert Fraser fraserofthenight at gmail.com
Fri Nov 23 11:33:26 PST 2007


Jarrett Billingsley wrote:
> "Leonard Dahlmann" <leo.dahlmann at gmail.com> wrote in message 
> news:fi6o8p$2i49$1 at digitalmars.com...
>> Janice Caron Wrote:
>>
>>> On 11/22/07, Gregor Richards <Richards at codu.org> wrote:
>>>> Janice Caron wrote:
>>>>> but for some reason
>>>>> "opStar" would not be high on my list of choices.
>>>> Because the names for operator overloads should be based on what
>>>> operator they're overloading, not the syntax for it.
>>>>
>>>> e.g. it's opMul, not opStar. opDiv, not opSlash.
>>> Yeah. Um. I was employing irony.
>>>
>>> Anyway, I'd hope Walter is considering changing the name, given the
>>> unanimous support here for doing that. The other part of my question
>>> though, was, is opWhateverAssign() on the cards any time soon. Any
>>> sign of an overload for *p = ?
>> What about *p *=, *p /=, *p ~=, ...?
>> Wouldn't these need overloads, too?
>>
> 
> Which is why we need reference returns.  Then you could do:
> 
> class A
> {
>     int myInt;
> 
>     ref int opDeref()
>     {
>         return myInt;
>     }
> }
> 
> A a = new A();
> *a = 5; // sets myInt to 5
> *a += 3; // sets myInt to 8
> 
> This would also solve the similar problems with opIndexAssign and with 
> properties. 
> 
> 

I believe there was some mention of reference types at the conference.



More information about the Digitalmars-d mailing list