Skip to content

Make xexprs serializable via read and write#5282

Closed
stevebyan wants to merge 2 commits intoracket:masterfrom
stevebyan:serializable-xexprs
Closed

Make xexprs serializable via read and write#5282
stevebyan wants to merge 2 commits intoracket:masterfrom
stevebyan:serializable-xexprs

Conversation

@stevebyan
Copy link
Copy Markdown

To enable this Scribble pull request: racket/scribble#498
make xexprs serializable via read and write by converting some structs to pre-fab structs.

The intent is to enable blogging systems like Greg Hendershott's "Tadpole", but using Scribble markup rather than Markdown. Greg gets away with serializing xexprs because he doesn't insert comments, CDATA, or PCDATA in his Markdown source.

Checklist

  • Bugfix
  • Feature
  • tests included
  • documentation

Description of change

Convert the comment, CDATA, and PCDATA structs to pre-fab structs.

I should add a test for serializing those structs, and amend the xexpr docs to mention that they are serializable.

stevebyan added 2 commits June 4, 2025 16:36
Make the xexpr structs prefab rather than transparent, so that they can be read and written.
The exception message is a bit different now.
@LiberalArtist
Copy link
Copy Markdown
Contributor

Convert the comment, CDATA, and PCDATA structs to pre-fab structs.

Using prefab structs is problematic. Currently, the constructors for these structs are provided with contracts, so (unless there are bugs in this library) a value that satisfies a predicate like cdata? is guaranteed to have valid contents. With prefab structs, however, anyone can construct invalid instances, e.g. #s(cdata #"not" #"valid" #"cdata").

Instead, these structs should be serializable in the sense of racket/serialize.

It is a bit fiddly to set up contracts to be checked during deserialization, especially because we don't want the performance overhead of struct-guard/c. I'm drafting a PR with the hard parts.

@LiberalArtist
Copy link
Copy Markdown
Contributor

LiberalArtist commented Jun 21, 2025

Also, location needs to be serializable because it can occur in source-start or source-stop.

LiberalArtist added a commit to LiberalArtist/racket that referenced this pull request Jun 21, 2025
LiberalArtist added a commit to LiberalArtist/racket that referenced this pull request Jun 21, 2025
@LiberalArtist
Copy link
Copy Markdown
Contributor

My serializable version is in #5283

@stevebyan
Copy link
Copy Markdown
Author

Thank you, LiberalArtist! Closing this pull request in favor of yours.

@stevebyan stevebyan closed this Jun 21, 2025
@stevebyan stevebyan deleted the serializable-xexprs branch June 21, 2025 20:40
LiberalArtist added a commit to LiberalArtist/racket that referenced this pull request Jun 23, 2025
Also, tweak docs and add `no-external-dtd`.

Increment version to 8.17.0.5.

Related to: racket/scribble#498
Related to: racket#5282
Related to: racket/rhombus#644
LiberalArtist added a commit to LiberalArtist/racket that referenced this pull request Jun 23, 2025
Also, tweak docs and add `no-external-dtd`.

Increment version to 8.17.0.5.

Related to: racket/scribble#498
Related to: racket#5282
Related to: racket/rhombus#644
mflatt pushed a commit that referenced this pull request Jun 24, 2025
Also, tweak docs and add `no-external-dtd`.

Increment version to 8.17.0.5.

Related to: racket/scribble#498
Related to: #5282
Related to: racket/rhombus#644
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants