[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Create a new table based on an already existed table (through Lua or C API)?
- From: 孙世龙 sunshilong <sunshilong369@...>
- Date: Fri, 22 Jan 2021 09:01:20 +0800
>It's complicated. You need to check each child table you copy against a
>list of already seen tables that you need to maintain as you work
>through everything.
I can't agree more.
>Much easier to write this directly in Lua than in C.
A self-defined function implemented by C makes easier for the users to
deep copy a table.
On Thu, Jan 21, 2021 at 9:17 PM Scott Morgan <blumf@blueyonder.co.uk> wrote:
>
> On 21/01/2021 12:51, 孙世龙 sunshilong wrote:
> > Thank you for your clarification.
> >
> > I think comparing the pointers of the outer table and inner table
> > could find out whether it's a recursive table or not.
> > Am I right? If I miss something, please let me know.
>
> It's complicated. You need to check each child table you copy against a
> list of already seen tables that you need to maintain as you work
> through everything.
>
> Much easier to write this directly in Lua than in C (see the
> lua-users.org link in an earlier post)