Thread overview
Put(...)
Sep 06, 2005
bobef
Sep 09, 2005
Walter Bright
Sep 09, 2005
bobef
Feb 19, 2006
bobef
September 06, 2005
= calls Put() but += doesn't (or I miss something?). I tried all verisions of Put()... Is there any other way to get notified when variable is modified by += operator.
What I mean:

var a=new mystuff;
a=5; // I get notified, Put() is called
a+=5; // nothing happens
September 09, 2005
"bobef" <bobef@lessequal.com> wrote in message news:dfl1nn$1pfq$1@digitaldaemon.com...
> = calls Put() but += doesn't (or I miss something?). I tried all
> verisions of Put()... Is there any other way to get notified when
> variable is modified by += operator.
> What I mean:
>
> var a=new mystuff;
> a=5; // I get notified, Put() is called
> a+=5; // nothing happens

Check out the code in opcodes.d under IRaddass:, that's what gets executed
for a +=. Either putVnumber() or putVstring() is called.


September 09, 2005
Walter Bright wrote:
> "bobef" <bobef@lessequal.com> wrote in message
> news:dfl1nn$1pfq$1@digitaldaemon.com...
> 
>>= calls Put() but += doesn't (or I miss something?). I tried all
>>verisions of Put()... Is there any other way to get notified when
>>variable is modified by += operator.
>>What I mean:
>>
>>var a=new mystuff;
>>a=5; // I get notified, Put() is called
>>a+=5; // nothing happens
> 
> 
> Check out the code in opcodes.d under IRaddass:, that's what gets executed
> for a +=. Either putVnumber() or putVstring() is called.
> 
> 
 Thank you, I'll check it out.
February 19, 2006
Adding this:

Dobject o_o=b.toObject();
if(o_o) o_o.Put(s,v,0);

after line 694 of opcodes.d seems to do the trick. I don't know if it is right to have zero for attributes and if it breaks something else but maybe time will tell (or Walter?). It is very nice because it could eliminate the need of setters/getters for certain functionality (like mywindow.setX() for example), which means less coding and less limitations, which is, I believe, cool. I don't know if it isn't against ECMA, but maybe it worths adding to the official distribution?

bobef wrote:
> Walter Bright wrote:
>> "bobef" <bobef@lessequal.com> wrote in message
>> news:dfl1nn$1pfq$1@digitaldaemon.com...
>>
>>> = calls Put() but += doesn't (or I miss something?). I tried all
>>> verisions of Put()... Is there any other way to get notified when
>>> variable is modified by += operator.
>>> What I mean:
>>>
>>> var a=new mystuff;
>>> a=5; // I get notified, Put() is called
>>> a+=5; // nothing happens
>>
>>
>> Check out the code in opcodes.d under IRaddass:, that's what gets executed
>> for a +=. Either putVnumber() or putVstring() is called.
>>
>>
>  Thank you, I'll check it out.