racket - Why consulting the readtable for skip-withespace -
i reading documentation readtable , in example there function skip-witespace
forward read next intressting character.
(define (skip-whitespace port) ; skips whitespace characters, sensitive current ; readtable's definition of whitespace (let ([ch (peek-char port)]) (unless (eof-object? ch) ; consult current readtable: (let-values ([(like-ch/sym proc dispatch-proc) (readtable-mapping (current-readtable) ch)]) ; if like-ch/sym whitespace, ch whitespace (when (and (char? like-ch/sym) (char-whitespace? like-ch/sym)) (read-char port) (skip-whitespace port))))))
the question why need read mapping readtable prior of testing white-space? in example not see mapping clobber character whitesapce.
Comments
Post a Comment