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

Discuss any general programming issues here
Post Reply
Bugala
Posts: 1168
Joined: Sun Feb 14, 2010 7:11 pm

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

Post 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)
User avatar
airsoftsoftwair
Posts: 5425
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

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

Post 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.
Post Reply