lua-users home
lua-l archive

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


Hello John,

I have a little class system here, written in lua, if you are interested
mail me off list.

                                    The God's Peace,

                                                                    Leandro.

----- Original Message -----
From: "John Paquin" <jpaquin@breakawaygames.com>
To: "Lua list" <lua@bazar2.conectiva.com.br>
Sent: Monday, December 15, 2003 7:16 PM
Subject: RE: Recognizing Methods vs. Functions


> Thanks Nick,
>
> You're right.  I'm trying to write a class structure, and want to have
> functions that are callable from the class description rather than the
> instance.
>
> But I just realized that Lua doesn't have to keep track of this
information
> after compile so there's nothing to look for.
>
> Thanks for the help!
>
> -----Original Message-----
> From: lua-bounces@bazar2.conectiva.com.br
> [mailto:lua-bounces@bazar2.conectiva.com.br]On Behalf Of Nick Trout
> Sent: Monday, December 15, 2003 4:07 PM
> To: Lua list
> Subject: RE: Recognizing Methods vs. Functions
>
>
> > From: John Paquin [mailto:jpaquin@breakawaygames.com]
> > Sent: Monday, December 15, 2003 12:53 PM
> > To: Lua list
> > Subject: RE: Recognizing Methods vs. Functions
> >
> > >> But you have to know what arguments a
> > >>  function takes in order to call it anyway
> > yeah, but...
> > I'm trying to look at the functions in a table and "sort" them into
> two
> > groups.  One that takes the self argument, and one that doesn't
> (assume
> > that
> > I have a valid reason for doing this).  I need to make the
> distinction,
> > and
> > I'd like to be able to do it automatically instead of using some hack
> > naming
> > convention to tell the difference.
> > Thanks
>
> Well in that case it may be a design problem? So this a little like
> having static and non-static functions mixed in a class in C++? If this
> is the case I'd declare them in 2 separate tables. Otherwise you could
> try declaring all the functions with explicit self, i.e.
>
>         function mod.foo(self, arg1, arg2) ... end
>
> and always call with the ':' convention, ignoring self where you don't
> need it.
>
> Nick
>
>
>