laurent.orseau
2020-8-19 09:25:50

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.


ryanc
2020-8-19 09:46:21

@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).


samdphillips
2020-8-19 16:16:41

It would seem to me that if 'dispatch-macromode 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.


notjack
2020-8-19 18:25:38

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


notjack
2020-8-19 18:27:57

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.


spdegabrielle
2020-8-19 18:33:04

XML


laurent.orseau
2020-8-19 18:36:26

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.


laurent.orseau
2020-8-19 18:38:22

You also get inheritance


notjack
2020-8-19 18:38:46

case in point :stuck_out_tongue:


notjack
2020-8-19 18:42:02

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


samdphillips
2020-8-19 18:48:26

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


notjack
2020-8-19 19:39:38

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