You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
if A contains B and B holds an owner reference to A, the owner reference (B'.owner) should point to the containing instance of A' instead of creating a new one.
There are several options:
Always use factories (A'.create) instead of constructor calls. This would allow some kind of caching of instances. Problem: this would be global, what about when you explicitly want different wrapper instances on the same delegate (for changeable wrappers)?
Using some kind of ThreadLocal: When the first constructor of a Wrapper is called, a mapper is initialized. All Wrappers are registered there and the factory checks whether the delegate has already been wrapped, if yes, the wrapped instance is returned. Problem: what if the same instance is used in different contexts? (Corner case) - Also, this might mean that KlumWrap must be available at runtime (instead of compile time only), since we need a place to store this ThreadLocal)
A Wrapper instance keeps references to all its direct wrapper children in a structure. When an inner wrapper ist instantiated, it is provided with its container as additional parameter. Whenever the child creates a wrapped instance, it is checked first against the container instance. This would mean rather complex logic
KlumWrap could have a direct depedency to KlumAST and handle the owner annotation as a special case
The text was updated successfully, but these errors were encountered:
if A contains B and B holds an owner reference to A, the owner reference (B'.owner) should point to the containing instance of A' instead of creating a new one.
There are several options:
The text was updated successfully, but these errors were encountered: