You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
typesetting/pitfall/restructure/versioned-struct.rkt

21 lines
732 B
Racket

#lang restructure/racket
(require racket/dict "struct.rkt")
(provide (all-defined-out))
#|
approximates
https://github.com/mbutterick/restructure/blob/master/src/VersionedStruct.coffee
|#
(define-subclass RStruct (RVersionedStruct type [versions (dictify)])
(define/override (decode stream [parent #f] [length 0])
(define res (send this _setup stream parent length))
(define version (cond
[(procedure? type) (type parent)]
[(is-a? type RBase) (send type decode stream)]
[else (raise-argument-error 'decode "way of finding version" type)]))
(report version 'yay)
#;(_parseFields stream res fields)
#;(send this process res stream)
res))