lua-users home
lua-l archive

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

> >From  Tue Mar 14 08:39:35 2000
> >From: "Maciej Maczynski" <>
> >
> >Is there a method in Lua to check from within a script if the function is
> >defined?
> 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,