0

Not sure exactly, but it makes various time I got a Error: variable is not properly set. in creation procedures' calling order. I figured out that creating class attributes before calling default_create seemed to solve the problem. Why is that so? It doesn't seem that default_create calls something in my make routine??!!!

Try to make an example even if I don't think I can reproduce it with a simple example...

Working

class A

feature

    attr: B

    make
        do
            create attr
            default_create
        end

end

Error: variable is not properly set.

class A

feature

    attr: B

    make
        do
            default_create
            create attr
        end

end
Alexander Kogtenkov
  • 5,770
  • 1
  • 27
  • 35
Pipo
  • 4,653
  • 38
  • 47

1 Answers1

2

default_create makes some calls. There may be a call on Current (direct or indirect, e.g. if Current is passed somewhere as an argument). If the attribute attr is not set at this point, the current object is not completely initialized and using it in regular feature calls may lead to calls on Void target (due to polymorphism, in particular). In order to avoid this issue, it is required to set all attributes before any calls involving Current.

Alexander Kogtenkov
  • 5,770
  • 1
  • 27
  • 35
  • So if I understood well you answer (the case is happening many times in multiple inheritence models) the proper systematic way to find the source of the error would be to search into all parents tree creation procedure calls if attributes are set before any `default_create` or creation procedure is called? – Pipo Feb 10 '19 at 20:20
  • @Pipo The systematic way is to search the call tree for uses of `Current`, for qualified calls and for attribute initialization. The error is caused by the combination of 3 factors: not all attributes are set, `Current` is used, there are qualified calls. Removing any of the factors solves the issue. One example of a systematic approach to avoid the error is in the library _Vision_, where `default_create` calls 3 features: one to set attributes, one to use `Current`, one to do the rest of initialization (e.g., to register event handlers). Descendants just redefine these 3 features. – Alexander Kogtenkov Feb 11 '19 at 07:47