I see lexikos' opinion at v1.1.16 alpha - Properties.
I don't know your counter-example. I hope you are not meaning to disable meta-function.lexikos wrote:the only satisfactory answer I came up with was to reduce the need for meta-functions - by implementing Properties
I haven't thought these carefully. Some discussion would be nice.
In my point, meta-function could support basic event on read/write/call variable of object.(only consider variables that invoke meta-function)
It's as basic as key button down/up. Class is just a template with event entrance, property is similar.
With these, user can simulate property / inherit / prototype-based class / object dot syntax (use read / write operate to invoke function) / public and private etc.
Some complexity comes from various variable accesses with one entrance (such as k1, k2, kn in __Get(k)).
For this case, a distribute/routine/filter mechanism/process is needed, maybe a multi-level filter to deal with various variable accesses. Or just about lexikos's new property?
We can handle well with one complex property, so why can't multiple.
I think
Code: Select all
property{
get{
}
set{
}
}
So I write a simple routine.Coco wrote:the purpose of Properties is to provide a user-friendly interface to users who want implement some sort of dynamic get / set behavior. __Get, __Set will still be available for dynamic properties -> key name(s) that you don't know in advance.
See post below with a AHK V1 demo.
Another simple custom property lib which look like a real property in this topic.
Code: Select all
class c{
__Get(k){
if PropertyOnGet(this,k,v)
return v
;..
}
;One simple implement
class OnGet{
Key1(){
}
}
;Or in key's view
class Key1{
OnGet(){
}
}
}
PropertyOnGet(o,k,ByRef v){
Property[this][k].OnGet(v)
;Change/Divide process to object based function.
;Maybe just a sub class/method of class "c" above.
}
I don't favour _(uderscore) prefix (i.e. MyProperty for interface key name, and _MyProperty for inner key name of value), it's just a non-compulsory protocol, like key word base - a normal key name or base which means prototype-based.
There will be ambiguity sometime, when key is a string with _ prefix.
lexikos wrote:this._myProperty is just another field where I happened to store the value. AutoHotkey does not make any connection between it and the property.
I think a simple / basic rule is better than various syntax / form.coco wrote:That was just lexikos' example, you don't have to follow it.
Some suggestion / guide / classic usage with rule would be more flexible and practical.
User can write / select their own template to handle property.
Also, I hope everything could be referenced / involved and changeable dynamic.
And avoid representation from becoming fixed and unchangeable.
I write this thread hastily, without careful consideration.
I'm anxious about "reduce the need for meta-functions".