Page 1 of 1

(save) + arrays

Posted: Wed Oct 10, 2012 1:47 pm
by kunt
hello.

it looks like (save) does not handle arrays correctly.
i have a 3-dimensional array and want to save it to a file for further re-initialization, but it fails.

what i get after (save) in a file:

Code: Select all

(set 'world-root (array 1 1 1 (flat '(
  (((nil 1 "data/maps/start.lisp")))))))
and if we eval this we get:

> (set 'world-root (array 1 1 1 (flat '((((nil 1 "data/maps/start.lisp")))))))
(((nil)))


which is not correct.
any suggestions?

ps: newlisp-10.4.3

Re: (save) + arrays

Posted: Thu Oct 11, 2012 12:38 pm
by johu
I don't know what your 3-dimensional array is meaning, sorry.
But I think

Code: Select all

> (set 'world-root (array 3 (flat '((((nil 1 "data/maps/start.lisp")))))))
(nil 1 "data/maps/start.lisp")
Or following?

Code: Select all

> (set 'world-root (array 3 1 1 (flat '((((nil 1 "data/maps/start.lisp")))))))
(((nil)) ((1)) (("data/maps/start.lisp")))
> (set 'world-root (array 1 3 1 (flat '((((nil 1 "data/maps/start.lisp")))))))
(((nil) (1) ("data/maps/start.lisp")))
> (set 'world-root (array 1 1 3 (flat '((((nil 1 "data/maps/start.lisp")))))))
(((nil 1 "data/maps/start.lisp")))

Re: (save) + arrays

Posted: Thu Oct 11, 2012 1:17 pm
by kunt
i initialize 3-dimensional array w/ only one element, as follows:
(define world-root (array 1 1 1 (list world-new-entry)))
the number of elements is being increased during the program execution. every element is a list.
and even this simple situation does not work.

for now i switched to lists entirely, they perform much better, after serialization i get:

Code: Select all

(set 'world-root '(
  (((nil 1 "data/maps/start.lisp")))))