It would be great if the keys would be set before base is assigned.
What do you think?
obj:= new _NotifyChange
Class _NotifyChange {
_base := {}
__Get(key){
return this._base[key]
}
__Set(key,val){
this._base[key] := val*2
Return
}
}
Posted 01 October 2011 - 03:00 PM
obj:= new _NotifyChange
Class _NotifyChange {
_base := {}
__Get(key){
return this._base[key]
}
__Set(key,val){
this._base[key] := val*2
Return
}
}
Posted 01 October 2011 - 11:05 PM
obj:= new _NotifyChange
Class _NotifyChange {
[color=red]__New() {
ObjInsert(this, "_base", {})
}[/color]
__Get(key){
return this._base[key]
}
__Set(key,val){
this._base[key] := val*2
Return
}
}Btw,It also makes the code shorter.Set: If the operation was successful, __Set should return the new value of the field, which may differ from the original r-value. This allows assignments to be chained, as in a.x := b.y := z. An empty string should be returned if the assignment failed, allowing the script to detect the error.
__Set(key,val){
[color=red]return [/color]this._base[key] := val*2
}
Posted 01 October 2011 - 11:26 PM
Posted 02 October 2011 - 07:50 PM
It's not debatable, it shouldn't!It's debatable whether the script would want the meta-functions to be skipped.
Posted 02 October 2011 - 08:23 PM
Possibly we could use local for that, would be great, I think?It's not debatable, it shouldn't!
Class _NotifyChange {
[color=red]local _base:={}[/color]
__Get(key){
return this._base[key]
}
__Set(key,val){
Return this._base[key] := val*2
}
}
Posted 02 October 2011 - 09:12 PM
Posted 03 October 2011 - 07:38 PM
Posted 03 October 2011 - 11:53 PM
Posted 10 October 2011 - 07:52 PM
Posted 10 October 2011 - 09:11 PM
Posted 11 October 2011 - 09:53 AM
should beIt's not debatable, it shouldn't!
At time of initialization everything is under control and can be done without the need to invoke the __Set() / __Get() metafunctions. So it makes more sense for me to call the meta-functions only after the initialization part is done...., it shouldn't invoke them!
Posted 11 October 2011 - 10:44 AM
Posted 11 October 2011 - 09:49 PM