
Use the prefab only for write/read. Of course you need to convert your good struct from/to prefab, but that should be easy. The user won’t see the prefab.

@notjack I haven’t tried this, but you can probably make custom types readable by adding a custom printer that writes them with a #reader
prefix. The read-accept-reader
parameter is off by default, so you’d have to turn it on to read the things back in. I suspect, though, that the result would be more difficult or less pleasant to look at, and that you would really want separate “print for humans to look at” and “print so the value can be reconstructed later” modes, in which case you might as well just use serialize
for the latter. Or maybe you could write a pretty-write/read-to-deserialize
procedure that preserves human-readability more than serialize
and uses #reader
notation so that reading the result (with read-accept-reader
on) automatically calls the deserializers (that is, reuse the existing serialization protocol).

It would seem to me that if 'dispatch-macro
mode for a readtable could key off of a tag instead of a single character it would go a fair way to making deserializing a “custom” type easier. You’d still have to mess with the readtable though.

If I’m already converting to a different format, why convert to prefabs? I could just convert to lists or something.

I really just think that “notation for humans” and “format for data transfer” are two completely separate problems and the same mechanism shouldn’t try to handle both. Hence why I don’t think read
and write
are suitable for data transfer.

XML

You could, but prefabs are more convenient: you have the ‘type’ name, and after reading you get a struct so you can access fields with a name rather than a position. Because of this, it should be fairly straightforward to convert from the prefab struct to you struct. This could probably even be automated, but I haven’t tried.

You also get inheritance

case in point :stuck_out_tongue:

I’m definitely automating the conversion regardless of which target format I use, so the convenience of the field accessors won’t matter

I think I’m in agreement. I was thinking about literal program syntax.

in programs I think s-expressions and require
is a perfectly fine solution