lua-users home
lua-l archive

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


Either I am doing something so stupid that I can't see it or something
fishy is going on. Consider this:

	function x(l)
		z=0
		l=nil
		return l
	end

	print(x("test"))

... which prints "nil". Fine.

Now simply comment out the first line of x() (ie "z=0") and try again...
this time it prints "test".

It seems that the first line of x() can be any valid Lua statement other
than "l=nil" and all works fine. However, if this assignment is the
first line it just doesn't work. I am puzzled.

(In case you wonder why anyone would set a function parameter to nil:
the above is stripped down to the smallest code snippet that shows this
behaviour. The original stuff comes from a more complex wrapper around a
bunch of functions in the Lua runtime library.)

That's Lua 5.1.1 on a Win2k SP4 rollup box. I checked with both the
latest precompiled binaries and a locally compiled version.

-- 
cheers  thomasl

web : http://thomaslauer.com/start