Page 1 of 1

dynamic property call

Posted: 06 Nov 2018, 20:28
by uname

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, I assume this is intended behavior, but why?

Re: dynamic property call

Posted: 07 Nov 2018, 11:22
by just me
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).

Re: dynamic property call

Posted: 07 Nov 2018, 11:32
by nnnik
I think this had something to do with conversion between 2 languages.
As just me quoted correctly AHK v2 doesn't allow this anymore.

Re: dynamic property call

Posted: 07 Nov 2018, 21:58
by lexikos
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...