[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Lua 5.2 wish item: Splicing
- From: Javier Guerra <javier@...>
- Date: Thu, 09 Nov 2006 19:24:51 +0100
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.