Menu

#1778 mixin's variable dictionnary at class level is not found

None
invalid
nobody
None
none
1
2021-08-11
2021-08-11
jfaucher
No

A variable exposed at class level by a mixin class is not visible from the class which inherits this mixin.
Reproductible with the attached script.
The output is
V (class level is ko)
1 (instance level is ok)

If I replace 'inherit' by 'subclass', the class level is ok.

When debugging RexxObject::getObjectVariables, it appears that the dictionnary for "mixin" is missing in the list.
receiver = class "c"
scope = "mixin"

dictionnaries chain:
c --> object --> NULL

1 Attachments

Discussion

  • Rick McGuire

    Rick McGuire - 2021-08-11
    • status: open --> invalid
    • Group: 5.0.0 --> None
     
  • Rick McGuire

    Rick McGuire - 2021-08-11

    This is not a bug with the variable dictionaries, but rather a misconception of how the classes are constructed and the init methods are invoked at the class level. At the time the init method is called on the .mixin class, it is just that class, not part of a hierarchy. So, only a class variable is set on the mixin class, which does not get pulled in when the class is constructed by the inherit.

    When the class is constructed using mixins, the class init method from the mixins is not called, so the variables are never initialized in that scope in the final class. You can verify this by adding a say "statement" to your init method in the mixin class. It is only called when mixin class is initially created, and not when the c class is instantiated. If you add a setter for the V attribute to your mixin and use it to assign a value, the value will stick.

     
  • jfaucher

    jfaucher - 2021-08-11

    ok, thanks for the explanations, that was interesting to read.
    I just discovered that if I replace 'init' by 'activate' then it works.
    That works also with ooRexx4 so that's fine.

     

Anonymous
Anonymous

Add attachments
Cancel





MongoDB Logo MongoDB