[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Chicken-users] Store data as text in scm files
From: |
Ivan Shmakov |
Subject: |
Re: [Chicken-users] Store data as text in scm files |
Date: |
Fri, 27 Dec 2013 14:08:11 +0000 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) |
>>>>> mfv <address@hidden> writes:
[…]
> ;; 2) store as evaluated code/data ("Joe Jackson" ("person" "X" "Y")
> (1 728 2812) ("address@hidden") ("S street" "T Town" "C Country"))
> Again, I am not sure how the actual implentation of writing data
> would be.
It could be as simple as calling (write DATA). Consider, e. g.:
- (define a '(jrh 42 (13 . 37)))
; no values returned
- (begin (write a) (newline))
(jrh 42 (13 . 37))
> As for reading, I would read the parse the text file (e. g. by
> reading \n separated string entries) and assign the text directly to
> a code structure.
It’s possible to simply (set! *database* (read)), provided that
*database* was written with (write *database*).
> This would happen a la (define somedata (<read-in-data>)) – or make
> hash-tables out of them, etc.
> ;; 3) store as text to be parsed by a parser "Joe Jackson" "person"
> "X" "Y" 1 728 2812 "address@hidden" "S street" "T Town" "C Country"
> The least practical solution, as it requires to write a parser.
To note is that there’re existent parsers for a number of
text-based data formats, such as XML, JSON, YAML, etc.
---
jrh:
- 42
- { car: 13; cdr: 37; }
[…]
--
FSF associate member #7257