From 9d86c221fb53ba31f15d333e56513b8bfff2cefa Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 23 Dec 2008 10:41:32 +0100 Subject: [PATCH] improvements in serialize suggested by D. Manura --- src/lib/serialize.lua | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/lib/serialize.lua b/src/lib/serialize.lua index 7bbe092..5052918 100644 --- a/src/lib/serialize.lua +++ b/src/lib/serialize.lua @@ -4,11 +4,11 @@ -- to the original one. The following are currently supported: -- * strings, numbers, booleans, nil -- * functions without upvalues --- * tables thereof. Tables cna have shared part, but can't be recursive yet. +-- * tables thereof. Tables can have shared part, but can't be recursive yet. -- Caveat: metatables and environments aren't saved. -------------------------------------------------------------------------------- -local no_identity = table.transpose { 'number', 'boolean', 'string', 'nil' } +local no_identity = { number=1, boolean=1, string=1, nil=1 } function serialize (x) @@ -33,7 +33,8 @@ function serialize (x) if type (x) == 'table' then nested [x] = true for k, v in pairs (x) do - if nested [k] then error "Can't serialize recursive tables yet" end + if nested [k] or nexted [v] + then error "Can't serialize recursive tables yet" end mark_multiple_occurences (k) mark_multiple_occurences (v) end -- 2.44.0