lua-users home
lua-l archive

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


On Tue, May 12, 2009 at 6:12 AM, David Manura <dm.lua@math2.org> wrote:
> There's many ways to do this [1], and its likely not possible to
> satisfy everyone with just one function.  As the differing
> implementations in Lua Gems 3 and 4 show, the main use cases are
> debugging and serialization.

Yes, trying to make one function (or one option) to handle these
different cases is awkward.

> The Lua equivalents of both of those would be respectively
>
>  -- Data::Dumper-like
>  var1 = {}
>  var1.a = var1
>
>  -- Data::Dump-like
>  (function()
>    local a = {}
>    a.a = a
>    return a
>  end)()

Interesting to see how Perl handles the problem, and it's a relief to
realize that there does not have to be 'one dumper to rule them all'.

> BTW, the name "pretty.write" is similar to io.write and suggests
> writing to a file or standard output, when it actually returns a
> string.  I suggest pretty.dump.

That is such a charmingly ugly name that I think I will adopt it ;)

steve d.