[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Q: A way to determine if function is defined
- From: "Maciej Maczynski" <macmac@...>
- Date: Wed, 15 Mar 2000 08:25:33 -0000
> >From email@example.com Tue Mar 14 08:39:35 2000
> >From: "Maciej Maczynski" <firstname.lastname@example.org>
> >Is there a method in Lua to check from within a script if the function is
> To check whether f(x,y,z,...) is ok, just do
> if type(f)=="function" then f(x,y,z,...) else do-something-else end
> However, this will not work if f is an object for which there is a
> tag method.
> >What I figured out, is trying to invoke the function in question using
> >"call", providing own handler.
> This should work in all cases.
> >Does anybody know nicer solution?
> What exactly are you trying to do?
I have embedded Lua in my "main" application. It is extended with bunch of C
functions (for data communications).
I also have a test program, which embedds Lua too, but (intentionally)
misses some functions, available only in "main" application.
I'd like the scripts to run both with test and "main" programs. Threre are
other solutions to that problem too, but
I just wanted to know how to "detect" function.
Thanks for quick answer,