Posted 28 November 2012 - 06:01 AM
So, I am practicing creating an API and I was wondering how you get the name of the table that a function is called from.
The way it works is supposed to be similar to the fs API so you can do:
ThingA = newMatrix()
where new matrix returns a table containing a bunch of functions
the you could do
ThingA:newRow()
where newRow is a function in the table "ThingA"
But, newRow requires the name of "ThingA" to be able to insert a new row into it.
How do get the name of the table "ThingA" without having to type
ThingA:newRow(ThingA)
?
The way it works is supposed to be similar to the fs API so you can do:
ThingA = newMatrix()
where new matrix returns a table containing a bunch of functions
the you could do
ThingA:newRow()
where newRow is a function in the table "ThingA"
But, newRow requires the name of "ThingA" to be able to insert a new row into it.
How do get the name of the table "ThingA" without having to type
ThingA:newRow(ThingA)
?