Post
by jeeswg » 05 Oct 2019, 04:58
- Is this your point ... The 'is' operator doesn't just compare the types of 2 objects, but the ancestry of 2 objects. And it can't be done in any other short-ish way in AHK currently? Crucially though, how is that usually done in other programming languages?
- (The functionality of 'is obj' is thus somewhat curious/unintuitive, if you had a function to perform that role, what would be a good descriptive name for it?)
- (Btw the use of 'directly or indirectly' is a bit confusing also, if C is derived from B, and B is derived from A, C is a *direct* descendant of A.)
- It's nice that we can override the class vars *within functions*, but the vast majority of AHK code is done in the global namespace, where the variable names would be(/currently are) prohibited.
- How would you feel if loadtime class variables were simply removed? You'd create a temporary class variable via a function if you wanted it. I would definitely prefer it that way, as I found when using Coco's JSON library as an example... I couldn't use JSON as a regular variable, and when I added local to all of my functions, I had to add global to all of my uses of the JSON variable. And if I'd obtained the JSON variable via a function, in all of my functions, none of that would have happened.
- And as a newbie, it's more intuitive that variables are variables, and there aren't special variables that you can't/'mustn't' overwrite (other than the clearly labelled A_ variables). It was unintuitive also that the mere existence of a class created a variable. Cf. functions where you have to call the function to make anything happen. (Functions that can quietly sit in the included libraries with no effect on the script.)
- Also, this seems to go against the AHK v2 trend of separating namespaces e.g. keys/properties/methods, by combining variable names/class names. Cheers.
- [EDIT:] Hmm, A_Classes.JSON.Load(vText) and/or Class("JSON").Load(vText) versus JSON.Load(vText) would have been more intuitive, and safer, and you can see it's class. And you wouldn't need #Warn ClassOverwrite.