v0.19 format reader and generic deserializer #1435

Merged
vyzo merged 72 commits from v0.19-serde-deserialize into v0.19-staging 2026-05-29 09:10:17 +00:00
Owner

Implement a reader that can read format output

Implement a reader that can read format output
vyzo changed title from format reader to v0.19 format reader and generic deserializer 2026-05-22 22:13:53 +00:00
fare left a comment

Just a few elements to get you going while I review the rest...

Just a few elements to get you going while I review the rest...
@ -233,3 +231,1 @@
(printable (and (not all-slots-printable?) (make-props! print:)))
(all-slots-equalable? (or transparent? (eq? #t (agetq equal: properties))))
(equalable (and (not all-slots-equalable?) (make-props! equal:)))
(def (no-alist? key alist)
Owner

Not a good function name. Suggestions:
all-slots?
all-slots-covered?
Or something like that.
Then a comment that says that unless there's an alist override, all slots are covered indeed.

Not a good function name. Suggestions: all-slots? all-slots-covered? Or something like that. Then a comment that says that unless there's an alist override, all slots are covered indeed.
Author
Owner

yeah, you right. renamed to has-no-alist-overide?

yeah, you right. renamed to has-no-alist-overide?
Owner

I much prefer naming the function after the ultimate intention than the implementation or representation detail. The implementation detail is obvious already by reading the source.

I much prefer naming the function after the ultimate intention than the implementation or representation detail. The implementation detail is obvious already by reading the source.
Author
Owner

sure, but this is an intentional name!

sure, but this is an intentional name!
Owner

Nah. First it's override, not overide, and I prefer a positive meaning all-slots-covered? or something is better.

Nah. First it's override, not overide, and I prefer a positive meaning `all-slots-covered?` or something is better.
Author
Owner

ok, let me find a better name.

ok, let me find a better name.
Author
Owner

sure, but this is an intentional name!its not though, its some slots. really a programmer override.
i'll fix the typo.

sure, but this is an intentional name!its not though, its some slots. really a programmer override. i'll fix the typo.
Author
Owner

fixed

fixed
fare marked this conversation as resolved
@ -236,0 +234,4 @@
(else #t)))
(let* ((transparent?
(agetq transparent: properties
Owner

Is the indentation funky only in the review window or do you need to fix it in the file?

Is the indentation funky only in the review window or do you need to fix it in the file?
Author
Owner

it was me, fixed.

it was me, fixed.
vyzo marked this conversation as resolved
@ -316,0 +318,4 @@
(cons klass (cdr subclasses)))))
(else
(set! (&class-type-properties super)
(cons [subclasses: klass] props)))))))
Owner

In general, I much prefer slots over properties. Ideally, properties as alist should only exist as syntax, and maybe as a mechanism for future-handled things. But not for regular properties used by the system.

In general, I much prefer slots over properties. Ideally, properties as alist should only exist as syntax, and *maybe* as a mechanism for future-handled things. But not for regular properties used by the system.
Author
Owner

i think its appropriate here. changing slots is a more heavy operation, lets reconsider in the future.

i think its appropriate here. changing slots is a more heavy operation, lets reconsider in the future.
Owner

Then let's open an issue to do these kinds of things properly.

You know what? If we do things properly, I can proudly document the Gerbil Way in the MOP chapter of my book.

Then let's open an issue to do these kinds of things properly. You know what? If we do things properly, I can proudly document the Gerbil Way in the MOP chapter of my book.
Author
Owner

upon in person discussion, lets follow up on this.

we also need a class lock, so it becomes a bootstrap pain i would like to avoid in this pr

upon in person discussion, lets follow up on this. we also need a class lock, so it becomes a bootstrap pain i would like to avoid in this pr
Author
Owner
#1437
@ -434,3 +450,3 @@
(slot-flags (vector-ref fields (fx+ i 1)))
(next-i (fx+ i 3)))
(if (fx= (fxand slot-flags 1) 0) ;; printable flag
(if (fx= (fxand slot-flags 1) 0) ;; printabke flag
Owner

WTF typo. You might want to install a typo-detector in your emacs config.

WTF typo. You might want to install a typo-detector in your emacs config.
Author
Owner

lol yes. fixing.

lol yes. fixing.
Author
Owner

fixed

fixed
vyzo marked this conversation as resolved
@ -440,3 +456,3 @@
(loop next-i
(fx+ offset 1)
(cons (cons slot-name offset) r))))
r)))
Owner

Yikes, what was that bug?

Yikes, what was that bug?
Author
Owner

yes.

yes.
vyzo marked this conversation as resolved
@ -289,0 +299,4 @@
(qsyntax :- :symbol) ; macro symbol for #` or #f
(unsyntax :- :symbol) ; macro symbol for #, or #f
(sunsyntax :- :symbol) ; macro symbol for #,@ or #f
)
Owner

Let's give the full names quasiquote, unquote-splicing, quasisyntax, unsyntax-splicing. It doesn't make sense to have some names clash with the official names and other not but use ad hoc abbreviations.

Let's give the full names quasiquote, unquote-splicing, quasisyntax, unsyntax-splicing. It doesn't make sense to have *some* names clash with the official names and other not but use ad hoc abbreviations.
Author
Owner

ok

ok
Author
Owner

fixed

fixed
vyzo marked this conversation as resolved
@ -8,3 +10,4 @@
./reader)
(export #t)
(def (format-write (writer : BufferedWriter) obj (env : WriteEnv))
Owner

Maybe rename to write-formatted, read-formatted?

Maybe rename to write-formatted, read-formatted?
Author
Owner

eh, it is somewhat inconsistent.

eh, it is somewhat inconsistent.
Author
Owner

basically its format, the subsystem, and its variants of read/write.

basically its format, the subsystem, and its variants of read/write.
fare marked this conversation as resolved
@ -0,0 +16,4 @@
(def reader-test
(test-suite "read format written objects"
(test-case "read integers"
(check (read-object-from-string "1234" (reader-environment))
Owner

Should (reader-environment) be an optional argument?

(With a test that it indeed behaves as such in the four cases that the parameter is overridden or not, vs specified explicitly or not.)

Should (reader-environment) be an optional argument? (With a test that it indeed behaves as such in the four cases that the parameter is overridden or not, vs specified explicitly or not.)
Author
Owner

probably, i'll change the signature but keep explicit for the tests.

probably, i'll change the signature but keep explicit for the tests.
Author
Owner

done

done
vyzo marked this conversation as resolved
@ -0,0 +162,4 @@
))
(def reader-dag-test
(test-suite "read dag format written objects"
Owner

Define a function for cases that work for the tree case, run them with dag and cycles too?
Define a function for cases that work for the dag case, run them with cycles too?

Define a function for cases that work for the tree case, run them with dag and cycles too? Define a function for cases that work for the dag case, run them with cycles too?
Author
Owner

thats something we can ask the LLM to do. lets create issue.

thats something we can ask the LLM to do. lets create issue.
Author
Owner
#1438
@ -0,0 +23,4 @@
=> ReaderEnv
(ReaderEnv
renv: (ReadEnv allow-class: allow-class?
allow-procedure: allow-procedure?
Owner

I don't understand ReaderEnv vs ReadEnv. And the name "renv" isn't great—maybe "read-env"? "opt" should also probably be "options".

I don't understand ReaderEnv vs ReadEnv. And the name "renv" isn't great—maybe "read-env"? "opt" should also probably be "options".
Author
Owner

lets the serde envs Context.
opt we use everywhere...

lets the serde envs Context. opt we use everywhere...
Owner

Well, then we need an issue to have longer names everywhere.

Well, then we need an issue to have longer names everywhere.
Author
Owner

renamed serde envs to contexts

renamed serde envs to contexts
Author
Owner

i am keeping opts, i call options opts everywhere and it doesnt cause confusion.

i am keeping opts, i call options opts everywhere and it doesnt cause confusion.
vyzo marked this conversation as resolved
@ -0,0 +31,4 @@
special: __special-readtable))
(def (parse (reader : BufferedReader)
(env : ReaderEnv)
Owner

indentation issue?

indentation issue?
Author
Owner

yes

yes
vyzo marked this conversation as resolved
@ -0,0 +93,4 @@
(def (parse-special (reader : BufferedReader)
(env : ReaderEnv)
(anchor : Anchor))
Owner

reindent?

reindent?
Author
Owner

done

done
vyzo marked this conversation as resolved
@ -0,0 +335,4 @@
(:- (##vector-ref __symbolic-delimiter-chars int)
:boolean))))
(def (parse-special-index (reader : BufferedReader)
Owner

I don't like the word "special" here. If it's for the sharp reader, maybe "sharp" instead?

I don't like the word "special" here. If it's for the sharp reader, maybe "sharp" instead?
Author
Owner

ok, will rename.

ok, will rename.
Author
Owner

renamed

renamed
vyzo marked this conversation as resolved
Author
Owner

fixed some indentation issues

fixed some indentation issues
fare approved these changes 2026-05-29 07:50:11 +00:00
fare left a comment

Minor typos, otherwise LGTM

Minor typos, otherwise LGTM
@ -47,3 +50,3 @@
(def (fold-format-ops-for-stx stx writer env ops)
(def (fold-format-ops-for-stx stx writer ctx ops)
(with-identifiers ((writer.write-char writer writer ".write-char-utf8")
Owner

Align?

Align?
vyzo marked this conversation as resolved
@ -1,4 +1,4 @@
;;; -*- Gerbil -*-
;;; -*- Gerbilo -*-
Owner

Is Gerbilo the miniKanren version of Gerbil?

Is Gerbilo the miniKanren version of Gerbil?
Author
Owner

no its me struggling with my new toy spaceship control keyboard

no its me struggling with my new toy spaceship control keyboard
vyzo marked this conversation as resolved
@ -15,13 +15,13 @@
(defstruct Formater
Owner

Proper spelling is Formatter

Proper spelling is Formatter
Author
Owner

ugh, fixing

ugh, fixing
vyzo marked this conversation as resolved
@ -0,0 +10,4 @@
./api
./reader
./io
./reader-test-support)
Owner

Uh, align?

Uh, align?
Author
Owner

it is, no?

it is, no?
Author
Owner

oh, readers together

oh, readers together
vyzo marked this conversation as resolved
vyzo merged commit bf93986359 into v0.19-staging 2026-05-29 09:10:17 +00:00
vyzo deleted branch v0.19-serde-deserialize 2026-05-29 09:25:01 +00:00
Sign in to join this conversation.
No description provided.