Add one-line comments to all defines in 5 spec files
parser.sx (3), render.sx (15), harness.sx (21), signals.sx (23), canonical.sx (12) — 74 comments total. Each define now has a ;; comment explaining its purpose. Combined with the evaluator.sx commit, all 215 defines across 6 spec files are now documented. primitives.sx and special-forms.sx already had :doc fields. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
;; Deterministic serialization for content addressing
|
||||
(define
|
||||
canonical-serialize
|
||||
:effects ()
|
||||
@@ -23,6 +24,7 @@
|
||||
(canonical-dict val)
|
||||
:else (str val))))
|
||||
|
||||
;; Normalize number representation (no trailing zeros)
|
||||
(define
|
||||
canonical-number
|
||||
:effects ()
|
||||
@@ -40,6 +42,7 @@
|
||||
(if (ends-with? trimmed ".") (str trimmed "0") trimmed))
|
||||
s)))))
|
||||
|
||||
;; Serialize dict with sorted keys
|
||||
(define
|
||||
canonical-dict
|
||||
:effects ()
|
||||
@@ -61,16 +64,19 @@
|
||||
sorted-keys))
|
||||
"}"))))
|
||||
|
||||
;; Compute SHA3-256 content ID from an expression
|
||||
(define
|
||||
content-id
|
||||
:effects ()
|
||||
(fn (expr) (sha3-256 (canonical-serialize expr))))
|
||||
|
||||
;; First 16 chars of content ID (short form)
|
||||
(define
|
||||
content-id-short
|
||||
:effects ()
|
||||
(fn (expr) (slice (content-id expr) 0 16)))
|
||||
|
||||
;; Create a bytecode module container
|
||||
(define
|
||||
make-bytecode-module
|
||||
:effects ()
|
||||
@@ -78,6 +84,7 @@
|
||||
(version source-hash code)
|
||||
(list (quote sxbc) version source-hash code)))
|
||||
|
||||
;; Type predicate for bytecode modules
|
||||
(define
|
||||
bytecode-module?
|
||||
:effects ()
|
||||
@@ -85,12 +92,16 @@
|
||||
(expr)
|
||||
(and (list? expr) (>= (len expr) 4) (= (first expr) (quote sxbc)))))
|
||||
|
||||
;; Get module format version
|
||||
(define bytecode-module-version :effects () (fn (m) (nth m 1)))
|
||||
|
||||
;; Get source content hash
|
||||
(define bytecode-module-source-hash :effects () (fn (m) (nth m 2)))
|
||||
|
||||
;; Get compiled bytecode
|
||||
(define bytecode-module-code :effects () (fn (m) (nth m 3)))
|
||||
|
||||
;; Create a code object (arity + constants + bytecode)
|
||||
(define
|
||||
make-code-object
|
||||
:effects ()
|
||||
@@ -104,6 +115,7 @@
|
||||
(set! parts (concat parts (list :upvalue-count upvalue-count))))
|
||||
(concat parts (list :bytecode bytecode :constants constants)))))
|
||||
|
||||
;; Create provenance record (author, timestamp, source)
|
||||
(define
|
||||
make-provenance
|
||||
:effects ()
|
||||
|
||||
Reference in New Issue
Block a user