Page 1 of 1

Is cross referencing a problem? (a.b = c, c.a = a)

Posted: Wed Dec 09, 2020 10:55 am
by Bugala
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:

Code: Select all

myOOP-units = {}

myOOP-World = {
units = myOOP-units
worldsize = 1
}
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:

Code: Select all

myOOP-units.world = myOOP-World
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:

Code: Select all

parentname = GiveMeParentTableNameOf(self)

Re: Is cross referencing a problem? (a.b = c, c.a = a)

Posted: Thu Dec 10, 2020 7:39 pm
by airsoftsoftwair
This shouldn't be a problem because all it does is setting a reference to the table and of course it's allowed to reference a table from within itself.

Getting the root table isn't possible, though.