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/utils.rkt

12 lines
521 B
Racket

8 years ago
#lang restructure/racket
8 years ago
(provide (all-defined-out) (rename-out [resolveLength resolve-length]))
8 years ago
(require "number.rkt")
8 years ago
(define (resolveLength len-arg [stream #f] [parent #f])
8 years ago
(cond
8 years ago
[(not len-arg) #f]
[(number? len-arg) len-arg]
[(procedure? len-arg) (len-arg parent)]
[(and parent (key? len-arg)) (ref parent len-arg)] ; treat as key into RStruct parent
[(and stream (NumberT? len-arg)) (send len-arg decode stream)]
[else (raise-argument-error 'resolveLength "fixed-size argument" len-arg)]))