[racket] serializable structs and portability

5 views
Skip to first unread message

Eric Tanter

unread,
Mar 28, 2011, 5:36:22 PM3/28/11
to racket
Hi,

I'm playing with serializable structs and noticed that the absolute path of the source rkt definition is inserted in the representation (I'm writing structs out to a file).
The problem is that if I then move my application to a server for deployment, all serialized structs cannot be deserialized anymore. If I edit/replace, it works, but I assume this is not the right way to proceed.

What is the best way to obtain "portable" serialized structs?

Thanks,

-- Éric

_________________________________________________
For list-related administrative tasks:
http://lists.racket-lang.org/listinfo/users

Matthew Flatt

unread,
Mar 28, 2011, 5:22:01 PM3/28/11
to Eric Tanter, racket
At Mon, 28 Mar 2011 17:36:22 -0400, Eric Tanter wrote:
> I'm playing with serializable structs and noticed that the absolute path of
> the source rkt definition is inserted in the representation (I'm writing
> structs out to a file).
> The problem is that if I then move my application to a server for deployment,
> all serialized structs cannot be deserialized anymore. If I edit/replace, it
> works, but I assume this is not the right way to proceed.
>
> What is the best way to obtain "portable" serialized structs?

If the struct is defined in a collection-based library, then the
serialized form will use the collection path instead of a filesystem
path. I think that's the only way currently to make the information
path-independent.

Eric Tanter

unread,
Mar 28, 2011, 6:28:02 PM3/28/11
to Matthew Flatt, racket
I'm not sure I understand what you mean by "collection-based library".

The structs are part of an app I'm building from scratch.
For now I have a couple of .rkt files, some of which define the structs in question, and I import them in the main module with (require "foo.rkt"), etc.

Suggestions?

Thanks,

-- Éric

Matthew Flatt

unread,
Mar 28, 2011, 10:33:08 PM3/28/11
to Eric Tanter, racket
At Mon, 28 Mar 2011 18:28:02 -0400, Eric Tanter wrote:
> I'm not sure I understand what you mean by "collection-based library".
>
> The structs are part of an app I'm building from scratch.
> For now I have a couple of .rkt files, some of which define the structs in
> question, and I import them in the main module with (require "foo.rkt"), etc.

I mean in a library that you require like

(require mystuff/foo)

or

(require (planet ....))

instead of

(require "foo.rkt")


Or a relative-path `require' is ok from some other module in the same
collection, as long as a collection path is used at some point.

Eric Tanter

unread,
Mar 29, 2011, 2:16:33 PM3/29/11
to Matthew Flatt, racket
Sorry I still don't get it.

Here's what I've tried:
- moved my application files to the user collects directory of my system.
- made the proper dir/subdir structure
- use only (require myapp/mod1) kind of requires

(It works ok)

Now if I serialize some structures in a file, they still get absolute path names.
Eg.:
((2) 5 ((#"/Users/etanter/Library/Racket/5.1/collects/bibdcc/main.rkt" . deserialize-info:order-v0)

I must be missing something. Any idea?

Thanks,

-- Éric

Matthew Flatt

unread,
Mar 29, 2011, 1:21:35 PM3/29/11
to Eric Tanter, racket
Are you starting the program by running "main.rkt" in DrRacket or with
something like

racket main.rkt [in the "bibdcc" directory]

?


If so, do you get a different result using

racket -l bibdcc

?

Eric Tanter

unread,
Mar 29, 2011, 2:29:50 PM3/29/11
to Matthew Flatt, racket
In the meantime I figured out that the structures that were defined not in main.rkt file but in another one got serialized properly. So I moved all definitions in a separate file, and now it works.

(running from DrRacket)

((2) 5 (((lib "bibdcc/structs.rkt") . deserialize-info:order-v0)
((lib "bibdcc/structs.rkt") . deserialize-info:book-v0)

-- Éric

Reply all
Reply to author
Forward
0 new messages