lua-users home
lua-l archive

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


> On Thu, Jun 22, 2000 at 04:45:01AM -0300, Mike Cuddy wrote:
> > I'm defining an "object class" by using a table, Which is better "style" ...
> > 
> > Should I define the "member functions" inside the table declarations for
> > the class, like this:
> > 
> >     FooClassTag = newtag();
> >     FooClassInstanceTag = newtag();
> >     FooClass = {
> > 	instanceTag = FooClassInstanceTag,
> > 	dataMember = defaultValue,
> > 	-- etc.
> > 
> > 	-- "member functions"
> > 	memberFunc = function (self, param)
> > 	    -- stuff ...
> > 	end
> >     }
> 
> I do the above. I was very happy when anonymous function declaration
> syntax was added for this very reason. I like that all the data and
> functions for a class are "contained" in one place here.

I've actually decided on the other format (declaring the functions using the
'implicit self' format); I think I prefer the above format,
but I don't like having to declare the 'self' parameter explicitly (call it
a C++ 'this' holdover ;-)

Is there a way to do anonymous functions inside of table constructors
with the implicit 'self' parameter?

something like:

    table zzz {
	fooFunc = function:(param)
	...
	end
    }

Another thing that really bugs me is the 'begin' 'end' stuff.  Since most
editors won't show matching begin/end but they will show matching { } pairs...
but this is a minor gripe ...

--
Mike Cuddy (mcuddy@FensEnde.com, MC312), Programmer, Daddy, Human.
Fen's Ende Software, Redwood City, CA, USA, Earth, Sol System, Milky Way.
I remember asking why ... Let it rain, and protect us from this Cruel Sun.

       Join CAUCE: The Coalition Against Unsolicited Commercial E-mail.  
                          <http://www.cauce.org/>