lua-users home
lua-l archive

Implicit Table Indexing/Creation

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


I thought I had spotted a patch awhile ago which came across this list.
It basically allowed for syntax like:
	local t, v;
	v = t.something.innerthing
In this case v would be nil, and the interpreter wouldn't get upset.
Likewise,
	t.something.innerthing = "foo"
would implicitly create the table t.something.
Is there a patch against 5.1 for this? Basically, amongst other less
shallow reasons, I'd much rather be able to do
	proc.slaves.max	= 10
	proc.slaves.min	= 3
rather than
	proc		= {}
	proc.slaves	= { max = 10, min = 3 }
which is still nicer than
	proc	= {
		slaves	= {
			max	= 10,
			min	= 3
		}
	}
Abstractly the namespace of the configuration is hierarchical, but
usually its nice to pretend its flat. And to do that the language needs
to play along.
-- 
William Ahern <wahern@barracudanetworks.com>
--------------------------------------------------
This message was scanned for Spam, Spyware and Viruses
For more information, please visit:
http://www.barracudanetworks.com

AltStyle によって変換されたページ (->オリジナル) /