Something wrong in document Topic is solved

Get help with using AutoHotkey (v2 or newer) and its commands and hotkeys
QiuDao
Posts: 18
Joined: 25 Mar 2021, 22:55

Something wrong in document

Post by QiuDao » 08 Apr 2021, 00:19

See the v2 documention on the official website "https lexikos.github.io /v2/docs/commands/Type.htm" Broken Link for safety

Code: Select all

Object_Type(Value) {
    if HasProp(Value, "__Class")  ; Ensures classes aren't reported as an instance of the base class.
        return "Class"
    while Value := Value.base
        if HasProp(Value, "__Class")
            return Value.__Class
    return "Object"
}
Shouldn't use HasOwnProp instead of HasProp?

lexikos
Posts: 9553
Joined: 30 Sep 2013, 04:07
Contact:

Re: Something wrong in document  Topic is solved

Post by lexikos » 08 Apr 2021, 03:02

Yes (I mean, no, it should use ObjHasOwnProp). It so happens that I have already prepared updates to this part of the documentation due to changes being made in the next alpha.

Also, "Class" is incorrect; it has been "Prototype" since instance and static members were separated.

Code: Select all

TypeOf(Value)
{
    if Value is Object && ObjHasOwnProp(Value, "__Class")
        return "Prototype"
    if (comClass := ComObjType(Value, "Class")) != ""
        return comClass
    while Value := ObjGetBase(Value)
        if ObjHasOwnProp(Value, "__Class")
            return Value.__Class
    return "Object"
}
I renamed it because it also works for values which aren't Object, and in the next alpha it will also work for generic COM wrapper objects.

Actually, I realize this version isn't quite correct because Value is Object will return false for prototype objects such as Integer.Prototype.

QiuDao
Posts: 18
Joined: 25 Mar 2021, 22:55

Re: Something wrong in document

Post by QiuDao » 08 Apr 2021, 05:36

@lexikos
So coincidentally, "to Prototype" is just what I was about to say.
Great work! 👍 I am so excited to wait for the next alpha coming soon where new improvements are stored for us!

Post Reply

Return to “Ask for Help (v2)”