From a68e9a19429b0b5e08800e8ec90be2f7402d9ff3 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Fri, 29 Nov 2024 20:01:56 -0500 Subject: [PATCH] Update docs and minor bugfix --- README.md | 2 +- compile.c | 2 +- docs/serialization.md | 7 +++++++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index ca61a18..6b41144 100644 --- a/README.md +++ b/README.md @@ -79,7 +79,7 @@ of many language features or the other example programs/modules in - [Easy interoperability with C](docs/c-interoperability.md) - Support for [POSIX threads](docs/threads.tm) and thread-safe message passing queues over [channels](docs/channels.tm). -- Built-in data serialization and deserialization for datatypes. +- Built-in [data serialization and deserialization](docs/serialization.md). ## Dependencies diff --git a/compile.c b/compile.c index 3307378..8c82c4b 100644 --- a/compile.c +++ b/compile.c @@ -3717,7 +3717,7 @@ CORD compile_type_info(env_t *env, type_t *t) type_t *non_optional = Match(t, OptionalType)->type; return CORD_asprintf("Optional$info(%zu, %zu, %r)", type_size(t), type_align(t), compile_type_info(env, non_optional)); } - case TypeInfoType: return CORD_all("TypeInfo$info(", CORD_quoted(type_to_cord(Match(t, TypeInfoType)->type)), ")"); + case TypeInfoType: return CORD_all("Type$info(", CORD_quoted(type_to_cord(Match(t, TypeInfoType)->type)), ")"); case MemoryType: return "&Memory$info"; case VoidType: return "&Void$info"; default: diff --git a/docs/serialization.md b/docs/serialization.md index ac3c0bf..ea21f90 100644 --- a/docs/serialization.md +++ b/docs/serialization.md @@ -67,3 +67,10 @@ c.next = @Cycle("B", next=c) The deserialized version of the data correctly preserves the cycle (`roundtrip.next.next == roundtrip`). The representation is also very compact: only 9 bytes for the whole thing! + +## Unserializable Types + +Unfortunately, not all types can be easily serialized. In particular, +`Thread`s, types, and functions cannot be serialized because their data +contents cannot be easily converted to portable byte arrays. All other +datatypes _can_ be serialized.