Re: object classes: redefine __Set() temporarily
Posted: 16 Jan 2018, 15:22
- Details? It's not a technical discussion per se. I'm going to rewrite CUSTOM CLASSES V. FUNCTIONS now, shuffle the content about a bit, and make it a bit clearer. [EDIT: Rewrite done.]
- Thanks for your latest responses. Btw re. communication, quite often person A gives a subtle hint about something to person B, half the time, person B doesn't understand what was meant, or forgets what was meant when they reread the thread, and almost nobody else who reads the thread gets it.
- [EDIT:] Re. the example and the number of parameters, yes, that's right, thanks for pointing it out (I hadn't noticed it). The key thing that drew my attention was this, which I suppose could be used in a custom __Set() meta-function, it gives each new object a specific class by setting the base, and it is an approach that is simpler than others.
x[p1] := new x.base
- [EDIT:] When storing keys in one or two subkeys of an array, it would be good to have a name for that, maybe a 'clash avoidance' class, or a '__Get forcer' class that always forces __Get() to be used when retrieving keys. Although wouldn't that sort of approach only be appropriate for arrays with a restricted number of dimensions, or a certain type of hierarchy.
- [EDIT:] I'll have a check over my queries list, before starting a new thread on enumerators.
- Terminology, keys:
obj[1] := "a" ;a key with a numeric name with a string value?
obj["a"] := 1 ;a key with a string name with a numeric value?
What is a 'string key' or a 'numeric key', or are they ambiguous terms?
- Terminology, subclass v. nested class:
I was interested in any uses for subclasses/nested classes, other than for use with an enumerator.
Question About Classes - Ask for Help - AutoHotkey Community
https://autohotkey.com/board/topic/8552 ... ntry545206
- Terminology, method v. meta-function:
Is the distinction that if you overwrite a method, with a custom method, the original functionality is lost, whereas if you overwrite a meta-function, with a custom meta-function, the original functionality is lost only if you use 'return' somewhere inside it. Or is the distinction something else?
- Btw I was thinking that maybe built-in and custom arrays need some kind of Push/Insert method, to allow you to do something like oArray.InsertEx({a:1,b:2,c:3}), to add keys to an existing array.
- Btw also, cheers for your object investigator script for AHK v2:
object classes: redefine __Set() temporarily - AutoHotkey Community
https://autohotkey.com/boards/viewtopic ... 33#p194533
Related to that, this could also be interesting:
[Lib] ObjDump / ObjLoad - Object Backup - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=6&t=3573
- Btw plus, your 2 meta-functions differ, but they look virtually identical, is there a key difference in practice?
- Thanks for your latest responses. Btw re. communication, quite often person A gives a subtle hint about something to person B, half the time, person B doesn't understand what was meant, or forgets what was meant when they reread the thread, and almost nobody else who reads the thread gets it.
- [EDIT:] Re. the example and the number of parameters, yes, that's right, thanks for pointing it out (I hadn't noticed it). The key thing that drew my attention was this, which I suppose could be used in a custom __Set() meta-function, it gives each new object a specific class by setting the base, and it is an approach that is simpler than others.
x[p1] := new x.base
- [EDIT:] When storing keys in one or two subkeys of an array, it would be good to have a name for that, maybe a 'clash avoidance' class, or a '__Get forcer' class that always forces __Get() to be used when retrieving keys. Although wouldn't that sort of approach only be appropriate for arrays with a restricted number of dimensions, or a certain type of hierarchy.
- [EDIT:] I'll have a check over my queries list, before starting a new thread on enumerators.
- Terminology, keys:
obj[1] := "a" ;a key with a numeric name with a string value?
obj["a"] := 1 ;a key with a string name with a numeric value?
What is a 'string key' or a 'numeric key', or are they ambiguous terms?
- Terminology, subclass v. nested class:
I was interested in any uses for subclasses/nested classes, other than for use with an enumerator.
Question About Classes - Ask for Help - AutoHotkey Community
https://autohotkey.com/board/topic/8552 ... ntry545206
- Terminology, method v. meta-function:
Is the distinction that if you overwrite a method, with a custom method, the original functionality is lost, whereas if you overwrite a meta-function, with a custom meta-function, the original functionality is lost only if you use 'return' somewhere inside it. Or is the distinction something else?
- Btw I was thinking that maybe built-in and custom arrays need some kind of Push/Insert method, to allow you to do something like oArray.InsertEx({a:1,b:2,c:3}), to add keys to an existing array.
- Btw also, cheers for your object investigator script for AHK v2:
object classes: redefine __Set() temporarily - AutoHotkey Community
https://autohotkey.com/boards/viewtopic ... 33#p194533
Related to that, this could also be interesting:
[Lib] ObjDump / ObjLoad - Object Backup - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=6&t=3573
- Btw plus, your 2 meta-functions differ, but they look virtually identical, is there a key difference in practice?
Code: Select all
__set(k,p*){
v := p.pop() . this.__a
return this.__o[k,p*] := v
}
__set(p*){
v := p.pop() . this.__a
return this.__o[p*] := v
}