lua-users home
lua-l archive

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


This is strange, I don't get the same behaviour ... How do you execute this piece of code ? I do write it into a file an then run the standalone lua on it with the following command line :

lua test.lua

Or I can make a dofile on it, and get same result. All these being tested with lua 4.0, lua 5.0alpha and lua 5.0beta

Peter Hill wrote:

Vincent Penne:
One way to get original lua 4 behaviour was

local x=123
do
  local x = x
  f = function() return %x end
end
x = 456
print (f())

Now this gives 123 with both lua 4 and 5 ...

Hmm. Something I don't understand here.

If I type in the above I get "nil" not "123". But if I wrap it in an extra
"do ... end" it works.

do
 local x=123
  do
   local x = x
   f = function() return %x end
 end
 x = 456
 print (f())
end

That doesn't make sense to me.

I type the original one in again (redfining "f" once more) and now I get
"456". What's going on here? =:O

*cheers*
Peter.