Entry { auther = "Donald E. Knuth", title = "Literate Programming", publisher = "CSLI", year = 1992, } Entry { auther = "Jon Bentley", title = "More Programming Pearls", year = 1990, publisher = "Addison-Wesley", }
local authors = {} function Entry (b) authors[b.auther] = true end dofile("data.txt") for name in pairs(authors) do print(name) end
function serialize (o) if type(o) == "number" then io.write(o) elseif type(o) == "string" then io.write(string.format("%q", o)) -- string.format("%q", str)でquoteとなる。適切にシリアライズして書き出しておかないと、読み込みした時にデータが崩壊してしまう。 else <その他の場合> end end