Regarding not using deserialize directly: I may be using deserialize in the
wrong way, but the following doesn't work (and I had tried that before
posting):

> (define-values (in out) (make-pipe))
> (write (~a (serialize '((0 1) (1 0)))))
"((3) 0 () 0 () () (q (0 1) (1 0)))"
> (write (~a (serialize '((0 1) (1 0)))) out)
> (deserialize (read in))
; car: contract violation
;   expected: pair?
;   given: "((3) 0 () 0 () () (q (0 1) (1 0)))"
; [,bt for context]

'read simply returns a string. On the other hand, using Philip's suggestion
works (although I can't say I fully understand the subtleties involved):

> (define serialized-string (~a (serialize '((0 1) (1 0)))))
> (with-input-from-string serialized-string (lambda () (deserialize
(read))))
'((0 1) (1 0))

Regarding pg-array, I thought (from the docs) that it allowed for
multi-dimensional arrays, but since I might need a similar functionality
for structs and the like, I thought that I should find another solution.

Thanks everyone for the quick response.

Cheers,

Marc


On Tue, Mar 21, 2017 at 5:58 PM, George Neuner <gneun...@comcast.net> wrote:

> On 3/21/2017 5:48 PM, Jon Zeppieri wrote:
>
> Ah, except apparently `pg-array` only supports arrays with dimension
> 1. So... that won't help.
>
>
> I *think* Ryan Culpepper fixed that a long time ago ... though the docs
> may never have been updated.  I had a workaround at the time and
> unfortunately I never did go back to verify the fix in later releases.
>
> George
>
>
> On 12/18/2014 09:03 PM, George Neuner wrote:
>
> Using 6.0.1.   I just painfully discovered that
>
>    (pg-array->list (list->pg-array (list)))
>    => ERROR
>    pg-array->list: expected argument of type <pg-array of dimension 1>;
> given: (pg-array 0 '() '() '#())
>
> The documentation for  list->pg-array  states that it produces an array of
> dimension 1.  However, if you pass an empty list, you get back an array of
> dimension zero which you then can't transform back to a list [ except by
> going straight to the internal vector ].
>
> My question is, "shouldn't these conversions be symmetric?"   I
> understand  an array with no elements is meaningless as an array, but
> Postgresql (ab)uses arrays as substitutes for lists and sets, so an empty
> array does have meaning.
>
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Racket Users" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/
> topic/racket-users/xAbm8mlPX-w/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> racket-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to