lua-users home
lua-l archive

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


The configuration system I'm using Lua for wants to create long lists of 
items. Something like this:

list {
	"one", "two", "three", "four"
}

I have a function that massages some data and returns some items to be 
included in the above list:

function fn(...)
	return "A", "B", C"
end

It's used like this:

list {
	"one", "two", "three", "four",
	fn {"some more data here"}
}

-> "one", "two", "three", "four", "A", "B", "C"

That works fine.

Unfortunately, multiple returns from a function are only concatenated to the 
list if the function is the *last* thing on the list. If it's somewhere in 
the middle of the list, only the first item is added.

list {
	"one", "two", fn {}, "three"
}

--> "one", "two", "A", "three"

This isn't what I need. I *have* to be able to add multiple items, because I'm 
going to want to call fn() several times while creating the list.

Are there any workarounds I can use to fix this? I can have fn() return a 
table, in which case the table gets added to the list, but it's still added 
as a single item where I actually want the contents of the item instead...

Any suggestions?

-- 
+- David Given --McQ-+ "P.S. If you do not receive this, of course it
|  dg@cowlark.com    | must have been miscarried; therefore I beg you to
| (dg@tao-group.com) | write and let me know." --- Sir Boyle Roche, in a
+- www.cowlark.com --+ letter