[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Forward declaration of a table and (closure) function
- From: Steve Litt <slitt@...>
- Date: Wed, 13 Jul 2011 21:54:35 -0400
On Wednesday, July 13, 2011 09:34:28 PM Ross Berteig wrote:
> At 06:21 PM 7/13/2011, Steve Litt wrote:
> >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})
>
> You want something like this:
>
> require "spreadsheet"
> local columns = spreadsheet.new{}
> -- THESE *MUST* BE IN SPREADSHEET COLUMN ORDER!!!
> -- IF THE SPREADSHEET CHANGES, CHANGE THIS LIST
> columns:newCol("recvdate" , {quantfield=false, fcn=this})
Thanks Ross,
Unfortunately that syntax didn't work -- it bombed on the (later)
definition of Columns.new().
I know the require syntax would definitely work just right if I made
the definition of Columns and Columns.new() in a separate module, but I
was trying to find a way to have them in the same file but lower down.
Thanks
STeveT
Steve Litt
Author: The Key to Everyday Excellence
http://www.troubleshooters.com/bookstore/key_excellence.htm
Twitter: http://www.twitter.com/stevelitt