Nesting troubles
Posted: Tue Jul 17, 2012 6:27 am
I'm pretty sure I don't know what I'm doing.
I'm trying to construct a math namespace, so I can call math.section.function().
inside my math namespace is the sine section.
so i can call math.sine.function().
my function is approximateSine().
so like math.sine.approximateSine().
THIS FUNCTION IS DONE SO I DON'T NEED TEH CODEZ.
so right now I have a table math = {},
and inside that table is a table sine = {},
and inside that table is a table that approximates sine, and a function that uses that table to more closely approximate sine.
so like, approximateSine() uses a SineApproxBase = {}.
but in order to calculate the table I need to loop through a different function, one that i only need to run once.
so i was gonna tack it on at the end but for variable scope i'd like to understand -
how can i set it up so that i run some construction code -
for loops and function calls and other things -
inside of a table.
because i have to construct SineApproxBase using a for loop.
but 90% of the variable should exist within the math.sine namespace.
i just would like to be able to run code inside of a table, but just once to construct/initialize it.
so am i just doing this wrong? is this even possible in this language?
the tutorials really don't seem to help much. not much on nesting.
read a bunch of class mimicing metatable like tutorials, but if they would've helped me i didn't get it.
not that it's so important right now, but I'm going to be running around willy nilly doing this to all of my code.
I'm trying to construct a math namespace, so I can call math.section.function().
inside my math namespace is the sine section.
so i can call math.sine.function().
my function is approximateSine().
so like math.sine.approximateSine().
THIS FUNCTION IS DONE SO I DON'T NEED TEH CODEZ.
so right now I have a table math = {},
and inside that table is a table sine = {},
and inside that table is a table that approximates sine, and a function that uses that table to more closely approximate sine.
so like, approximateSine() uses a SineApproxBase = {}.
but in order to calculate the table I need to loop through a different function, one that i only need to run once.
so i was gonna tack it on at the end but for variable scope i'd like to understand -
how can i set it up so that i run some construction code -
for loops and function calls and other things -
inside of a table.
because i have to construct SineApproxBase using a for loop.
but 90% of the variable should exist within the math.sine namespace.
i just would like to be able to run code inside of a table, but just once to construct/initialize it.
so am i just doing this wrong? is this even possible in this language?
the tutorials really don't seem to help much. not much on nesting.
read a bunch of class mimicing metatable like tutorials, but if they would've helped me i didn't get it.
not that it's so important right now, but I'm going to be running around willy nilly doing this to all of my code.