lua-users home
lua-l archive

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

"Mark Edgar" <> wrote:
> A block is not a scope -- there is no scope expect where there is a
> (local) variable to have one.  The only way for multiple definitions
> to have the same scope is that they are declared in the same statement
> (or parameter list).

Perhaps I misunderstand you but I think that's not the case. You can
have one statement with a local declaration at the top of the file and
several longish functions later you can have another declaration that
silently overrides the first:

local i,j,k,dmz,x,y,z=1,2,3,0,4,5,6

function blahblah1(...)

-- and much more blahblahX()

local dmz=7

I am not arguing that this shouldn't happen, I am just saying that it
came as a surprise and that the manual could usefully give an explicit
warning in section 2.3 as well.

> (function(a,a,a) print(a); end)(1,2,3) -- prints 3

I have noticed that too and I must say that this specific case leaves me
with a certain strange feeling. Having two parameters with the same name
is almost 100% an error, so a warning might be appropriate... if the
compiler could warn.

Anyway, it's not a big deal, just something that might make the life of
other newbies a little easier.