[racket] Suggestion for saving preferences

From: Neil Van Dyke (neil at neilvandyke.org)
Date: Tue Apr 5 00:35:53 EDT 2011

Eduardo Bellani wrote at 04/04/2011 11:49 PM:
> * Create some functions like algorithm->list list->algorithm. The only drawback I see is that I will have to create variations for each struct.
>   

A few options...

Instead of a procedure like "algorithm->list" for each struct, what 
about defining "prop:custom-write" for each struct?

For implementing the writing for each struct, you could use a macro that 
expands to both a definition of the struct and its custom writer.

For reading, a few alternatives, which could work with almost the same 
human-readable data write format: (1) extend the Racket reader to read 
your struct format; (2) implement your own reader; (3) load the written 
data as code.

-- 
http://www.neilvandyke.org/


Posted on the users mailing list.