Is cross referencing a problem? (a.b = c, c.a = a)
Posted: Wed Dec 09, 2020 10:55 am
I am in a situation where it seems like variable A needs to hold B as one of its subvariables, but where variable B should also hold variable A in one of its variables, and I wonder if this is a safe way to do it.
Basically Idea is that I have these two OOP-objects where other OOP belongs as one of other OOPs variables. However, I need to have info from the original OOP constantly, hence I would need a way to access original OOP inside the other OOP.
as example:
then when using this myOOP-units, i constantly come to a situation where I need to know the worldsize from myOOP-World.
Is it therefore safe to have:
Or can this cause a problem?
for isnt this basically just a reference to myOOP-World, hence not taking much space etc. and not being a problem?
Also, is there any way that I could access this info through myOOP-units, without having it stored?
as in:
Basically Idea is that I have these two OOP-objects where other OOP belongs as one of other OOPs variables. However, I need to have info from the original OOP constantly, hence I would need a way to access original OOP inside the other OOP.
as example:
Code: Select all
myOOP-units = {}
myOOP-World = {
units = myOOP-units
worldsize = 1
}
Is it therefore safe to have:
Code: Select all
myOOP-units.world = myOOP-Worldfor isnt this basically just a reference to myOOP-World, hence not taking much space etc. and not being a problem?
Also, is there any way that I could access this info through myOOP-units, without having it stored?
as in:
Code: Select all
parentname = GiveMeParentTableNameOf(self)