[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: assignments to nil, as a drain (Re: allowing value evaluations as statements)
- From: Asko Kauppi <askok@...>
- Date: Thu, 4 Jan 2007 02:51:46 +0200
Brought me to think of this, opinions?
==== assignment to 'nil' (drain) ====
In Lua, "_= value" is often used to drain values. Or even "_,_, some=
f()"
This is okay, but causes two problems:
- "_" needs to be declared 'local' if used with -lstrict checking
- the value _is_ actually stored, and may cause surprises (you should
never USE it)
Allowing 'nil' to be used on left side of assignments would 'fix'
this, providing
a value drain without readback possibility (s.a. /dev/null).
nil,nil, some= f()
Another issue is use of 'local' with such constructs:
local nil,nil, some= f()
Should the use of 'nil' be allowed there, simply ignored. Maybe not,
this does look fishy..
So we need to also in the future:
local some
nil,nil, some= f()
One way could be officially declaring '_' as an always-local, always-
nil drain variable. :)
This sounds un-Lua-ish, but is actually very close to how it's
already treated.
-asko
David Manura kirjoitti 4.1.2007 kello 0.35:
On 31-Dec-06, at 9:56 PM, askok <at> dnainternet.net wrote:
_= nsfm:copyPath( testfile, newfile )
or error "File copy failed!"
Currently, Lua does not allow leaving the "_=" away, since that
would make these commands and commands don't have a value ('or'
gives this a value).
The wiki page on this is here:
http://lua-users.org/wiki/ExpressionsAsStatements
-davidm