lua-users home
lua-l archive

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


As far as I can tell

    function Var() ... end

will register a global function with the name "Var", even if
you make this declaration inside another function.

But 

    Var = function() ... end

Will only assign an "anonymous" function to the variable "Var", 
and you could have declared "Var" as a local variable.

So they are not really syntactic sugars. There are rules you
have to follow when declaring 

	function Var() ... end

Regards,
.paul.

On Mon, Mar 25, 2002 at 06:41:09PM -0000, nikdo79 wrote:
> Hi there,
> 
> Today i wanted to do this:
> 
> 
> Table={}
> local Function="MyFunction"
> function Table[Function] ()
>    print("Hello World")
> end
> 
> and i got an error!
> 
> I thought 
> 
> function Var() ... end
> 
> was full "syntatic sugar" for
> 
> Var = function () ... end
> 
> but it sad-to-know isn't because
> 
> Table[Function] = function () 
>    print("Hello World")
> end
> 
> works fine.
> 
> What's the Problem? A Bug? Or even intenion?
> 
> Regards,
>    Dominik
> 
> 
>