lua-users home
lua-l archive

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


>From lua-l@tecgraf.puc-rio.br  Tue Mar 14 08:39:35 2000
>From: "Maciej Maczynski" <macmac@xdsnet.de>
>
>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 "function"
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?
--lhf