Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Immutable String Buffers

Name: Anonymous 2011-09-17 22:28

Why is this telling me to concatenate small strings to the ends of large ones, but not in reverse, and then concatenate all remaining strings in the table?
http://www.lua.org/pil/11.6.html

Wouldn't it just be easier to put all the strings in a table then concatenate them all at once, as in the following?

function filetostring(file)
    local t == {}
    for line in io.lines(file)
        if line == "" then
            break
        end
        table.insert(t, line .. '\n')
   return table.concatenate(x)
end

I'm confused as fuck.

Name: Anonymous 2011-09-17 23:05

>>6
That's what I thought, but then why is "Programming in Lua", by the Chief Architect of the language, telling me to do something less efficient. Is it just to prove a concept? It reads as if he thinks it's faster.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List