lua-users home
lua-l archive

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


On Mon, Oct 06, 2014 at 12:50:32PM +0200, Charles Smith wrote:
> It's said that it's not necessary to have forward declarations, but then
> what's wrong with this:
> 
>     v = m1
> 
>     function m1 ()
>         print ("hello world")
>     end
> 
>     v()a

In the first line, you set v to m1 (which is nil).  Then you give m1 a
value.

Remember that:
	function m1()
is just sugar for
	m1 = function()

You wouldn't expect this to work, either:
	v = m1
	m1 = "foo"
	assert(v == m1)

B.