dynamic property call

Report problems with documented functionality
User avatar
uname
Posts: 18
Joined: 25 Oct 2013, 12:50

dynamic property call

06 Nov 2018, 20:28

Code: Select all

class c {
    p {
        get {
            return 42
        }
    }
}

MsgBox % {base: c}.p()
For some reason calling a property as a method leads to get execution.

It's been a while since 1.1.16.01, I assume this is intended behavior, but why?
just me
Posts: 6464
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: dynamic property call

07 Nov 2018, 11:22

It's not restricted to dynamic calls:
v2-changes -> Objects
Properties defined within a class no longer handle call (by calling the property getter). That is, obj.MyProperty() throws an exception unless a method with that name exists (it may be defined in a base class of the one which defined the property).
User avatar
nnnik
Posts: 4242
Joined: 30 Sep 2013, 01:01
Location: Germany

Re: dynamic property call

07 Nov 2018, 11:32

I think this had something to do with conversion between 2 languages.
As just me quoted correctly AHK v2 doesn't allow this anymore.
Recommends AHK Studio
lexikos
Posts: 6483
Joined: 30 Sep 2013, 04:07
GitHub: Lexikos

Re: dynamic property call

07 Nov 2018, 21:58

v1 allows a.b(x) := y to mean a.b[x] := y, even though a.b(x) and a.b[x] can potentially do two different things. Properties defined in a class provide some symmetry (though only for some objects) by making a.b(x) equivalent to a.b[x] (where b is the property).

v2 does not allow a.b(x) := y or permit 'call' for properties.

All property calls are dynamic...

Return to “Bug Reports”

Who is online

Users browsing this forum: No registered users and 6 guests