[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: calling a function who's name is contained within a string variable
- From: "Timm S. Mueller" <tmueller@...>
- Date: Tue, 21 Jul 2009 21:18:19 +0200
On Tue, 21 Jul 2009 20:03:49 +0100
"Sean Farrow" <sean.farrow@seanfarrow.co.uk> wrote:
> I havethe name of a function I wish to call in a string passed to me in
> this case through shared memory.
>
> Is there a way of calling this function in lua?
It depends on where the function value is known under the name
(functions have no names in Lua). The most generic form would be
getfenv()[string]()
Given that a function under the given name is known in the global
environment, you could also write
_G[string]()
or, if the function value is stored in some other table
table[string]()
--
Timm S. Mueller <tmueller@schulze-mueller.de>
Schulze & Mueller GbR, Gryphiusstr. 2, 10245 Berlin,
Gesellschafter: Franciska Schulze, Timm S. Mueller,
Tel. +49 30 93624410, http://www.schulze-mueller.de/