lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hi all,

In a program I'm doing "OOP" using a table called Columns and a 
function called Columns.new() containing several other functions that 
become, for want of a better word, "methods".

The purpose of this construct is as use-modifiable setup, so I'd like 
to have the calls to it at the very top of the program, where users 
expect user-modifiable stuff to be. So what I'd like at the top would be 
something like:

columns = Columns.new({})
-- THESE *MUST* BE IN SPREADSHEET COLUMN ORDER!!!
-- IF THE SPREADSHEET CHANGES, CHANGE THIS LIST
columns.newCol("recvdate"  , {quantfield=false, fcn=this})
columns.newCol("fname"     , {quantfield=false,  fcn=this})
columns.newCol("lname"     , {quantfield=false,  fcn=this})

Trouble is, these bomb if Columns and Columns.new() are defined below 
them. I can do this above them:

local Columns

and then define Columns below, but if I do this:

local Columns, Columns.new

then it bombs with: 
slitt@mydesk:/d/at/lua/massmail$ ./colnames.lua 
/usr/bin/lua: ./colnames.lua:3: unexpected symbol near '.'
slitt@mydesk:/d/at/lua/massmail$

Is there a syntax to forward declare both Columns and Columns.new(), 
or will I have to byte the bullet and make those definitions in a 
separate file that I must require?

Thanks

SteveT

Steve Litt
Recession Relief Package
http://www.recession-relief.US
Twitter: http://www.twitter.com/stevelitt