[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: How to save a complete table?
- From: William Ahern <william@...>
- Date: Fri, 4 Jan 2013 21:08:47 -0800
On Sat, Jan 05, 2013 at 02:41:07AM +0100, lihwa@gmx.com wrote:
> Greetings to all Lua programmers,
>
> I want to save a complete table, as it is, to a file. According to the
> information at http://lua-users.org/wiki/SaveTableToFile, it is not
> possible, because "Userdata, Functions, Metatables" will not be saved.
> This is a serious restriction.
Can you identify any other language that supports saving those kinds of
things out-of-the-box? I can't think of any whatsoever.
I agree it's a serious restriction. But so is being mortal, or lacking the
ability to levitate ;)
> Is there a way to save a complete table, without restrictions?
Do it the way languages like Java do it--implement a `serializable'
interface for complex objects that the language is incapable of serializing
itself. But first consider how you might do that for something like an open
file handle, a network socket, or a reference to a C function. You might
have to stop short of the ideal unless you have lots of time on your hands.