lua-users home
lua-l archive

Re: Lua 5.2 wish item: Splicing

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


Mark Hamburg wrote:
I'm thinking that something along the following lines would be useful:
 column{
 spacing = 10,
 $makeChildren(),
 view{
 title = "footer",
 }
 }
Where the $ means that we take all of the results from the function rather
than just the first. (And if it has no results, we also reflect that.) I
would also be quite open to other syntaxes.
i'd prefer to have it the other way around, that is using all values by default.
e.g, having this multivalue function:
function foo ()
	return 1,2,3
end
the function itself returns all values, and all values are used:
foo() => 1,2,3
{foo()} => {1,2,3}
{0,foo(),4} => {0,1,2,3,4}
bar(foo ()) => bar(1,2,3)
bar(0,foo(),4) => bar(0,1,2,3,4)
but wrapping the call with parenthesis, only the first returned value is used:
(foo()) => 1
{(foo()} => {1}
{0,(foo()),4} => {0,1,4}
bar((foo())) => bar(1)
bar(0,(foo()),4) => bar(0,1,4)
unfortunately, it would break a lot of old code.

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