Enclosing Object

BlitzMax Forums/BlitzMax Beginners Area/Enclosing Object

Is there a way for an object that is a field of another object to reference the enclosing object? Sort of like super references the parent object?

For example:
Type TOuterObject
   field innerobject : TInnerObject
end type


I want a method in TInnerObject to be able to call a method in TOuterObject without having to tell TInnerObject who TOuterObject is. It seems TInnerObject must know who it is a member of?

Thanks,
Jim

There is no such facility unless you save a reference to the parent object.

Seems like it would be handy and an easy thing to implement in the language. I would think internally the object must be aware of what object it is a member of.

>I would think internally the object must be aware of what object it is a member of.

Nope.

In delphi, every object has a field called owner, handy eh?

That's part of its implementation, not the actual language.

I never said it was part of the language. It's part of the "object" implmentation which everything is descended from.

What if an object has more than one owner?

I think the most elegant solution is to pass the 'owner' object along as a parameter on any methods you might want to invoke.