lua-users home
lua-l archive

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


It wouldn't be that hard to implement an "iscallable" function, would it?
This would return true if lua_isfunction returns true, or if the object in
question has the appropriate tag method(s) set. Maybe that's just overkill.

Eric

> -----Original Message-----
> From: owner-lua-l@tecgraf.puc-rio.br
> [mailto:owner-lua-l@tecgraf.puc-rio.br]On Behalf Of Diego Fernandes
> Nehab
> Sent: Monday, November 26, 2001 5:36 PM
> To: Multiple recipients of list
> Subject: Re: Function Existence
>
>
> On Mon, 26 Nov 2001, Edgar Toernig wrote:
>
> > > I would check lua_type, instead of lua_isnil, just for safety.
>
> > Just as a side note: I don't like these checks for function type.
> > Every type is possibly callable.  What about tables that implement
> > the function tag method?  Using isnil to decide whether an object
> > was given or not is OK, but explicitly enforcing a function type
> > is IMHO wrong.
>
> The original question  was about a way  to find out wether  a method was
> defined in the global scope or not.
>
> I agree that enforcing the isfunction might be too restrictive, but just
> using isnil and then calling the object will raise an error if it is not
> "callable".
>
> So, either you have to deal with the possible errors, or do the more
> restrictive way. It depends on your application.
>
> Regards,
> Diego.
>