Re: Positioning of cyclic ports
Peter McGoron 09 Jul 2026 19:20 UTC
> It doesn't promise the programmer who's trying to write portable
code anything at all.
For ultra-portable code, it doesn't, but for code that is written for a
smaller-but-still-broad-class of implementations (maybe the code has
other requirements, like syntax-case) then it is something they can rely on.
I think the bigger point of specifying positioning is to clarify what it
means to position to e.g. byte 1,000,000 of a size 13 bytevector.
An issue with port positions is what `port-position` should return.
Should it maintain an absolute counter from zero of bytes it has output,
or should it wrap around? i.e.
(define port (open-cyclic-input-bytevector #vu8(1 2 3 4 5 6 7)))
(set-port-position! port #e1e6)
(= (port-position port) (mod #e1e6 7))
;; or
(= (port-position port) #e1e6)
(Today I learned that 7 divides 999999.)
-- Peter McGoron