I have a set of nested objects, and need to get a slot from the containing object. Can it be done?
Example:
Foo := Object clone do(
a := "hello"
Bar := Object clone do(
b := Foo a # How to get `Foo a` here?
)
)
From the above code, I get an exception in the nested object Bar
when accessing Foo
:
Exception: Object does not respond to 'Foo'
The reason I would like to have these as nested objects, is because it would make it easier (IMO) to make the application more modular. If it was possible I could easily do something like
Foo := Object clone do(
someSlot := "Some value"
Bar := doRelativeFile("./folder/bar.io")
)
and in folder/bar.io
use Foo someSlot
if needed.
Think of e.g. someSlot
as a database connection, and Bar
as a data-model needing that database connection.