lua-users home
lua-l archive

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


Hi,

Gavin Wraith wrote:
> If the final string is actually needed, that is clearly the way to go.
> In practice, it very rarely is needed. Usually the rope/stringle (sorry
> "stringle" was an extemporization) gets written out to a file. The point
> is that ropes are very easy to program in Lua. I doubt whether managing
> them at the C level gains one very much. 

Generally design I/O functions in C to handle both multiple
arguments and nested tables from Lua. Very easy to work with
on the Lua side. And fast, too.

Example:

output("foo".."bar".."baz")      -- Slow. Avoid single arg I/O APIs.

output("foo", "bar", "baz")      -- Allow multiple arguments.
output{"foo", "bar", "baz"}      -- Allow tables.
output({"foo", {"bar"}}, "baz")  -- Allow nested tables. Mixing args is ok.

Bye,
     Mike