www.digitalmars.com         C & C++   DMDScript  

DMDScript - Put(...)

reply bobef <bobef lessequal.com> writes:
= 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
Sep 06 2005
parent reply "Walter Bright" <newshound digitalmars.com> writes:
"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.
Sep 08 2005
parent reply bobef <bobef lessequal.com> writes:
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.

Sep 09 2005
parent bobef <bobef lessequal.com> writes:
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.


Feb 19 2006