[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: local function xxx and local yyy= function
- From: "Alex Davies" <alex.mania@...>
- Date: Wed, 31 Dec 2008 11:46:24 +0900
Why lua do not make them(local function xxx and local yyy= function) as
Because the scope of "local yyy" doesn't begin until the next statement.
Makes things like this possible:
local temp = a + b
local temp = temp * 2
Where as if they were the same the second line would throw a arithmetic on
nil error. (or even worse, that position may be entirely uninitialized).
To special case functions would be very difficult for the parser (and
confusing), as you may have a scenario like this:
local temp = function() return temp end or temp
Where each use of temp is a different one.