Re:Q: A way to determine if function is defined [repost]

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Re:Q: A way to determine if function is defined [repost]

Luiz Henrique de Figueiredo
listproc choked in this one. --lhf

>From [hidden email]  Tue Mar 14 09:20:57 2000
>Date: Tue, 14 Mar 2000 12:18:55 GMT
>From: "Paul Winwood"<[hidden email]>
>To: <[hidden email]>
>Subject: Re:Q: A way to determine if function is defined 

Hi,

Assuming that I understand your question correctly then
I use the built in function 'type' which returns the type of 
the referenced object which for a function is the string 'function'.
for example consider the following LUA fragment:

function named()
end

-- note: noname is not declared.

write("type of 'named' is "..type(named).."\n")
--> returns type of 'named' is function
write("type of 'noname' is "..type(noname).."\n")
--> returns type of 'noname' is nil

Regards,
Paul.

____________________Reply Separator____________________
Subject:    Q: A way to determine if function is defined 
Author: <[hidden email]>
Date:       14/03/2000 08:32

Hi everybody,

Is there a method in Lua to check from within a script if the function is
defined?
I mean, before "call expression not a function" error appears.
What I figured out, is trying to invoke the function in question using
"call", providing own handler.
Does anybody know nicer solution?

Maciej