[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Fwd: How to forward declare globals
- From: Rob Kendrick <rjek@...>
- Date: Mon, 6 Oct 2014 11:53:25 +0100
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.