[plt-scheme] read-delimited-list
At 18 Aug 2006 23:09:54 -0000, Paul Graham wrote:
> Is there some equivalent of cl read-delimited-list in mzscheme?
>
> I'm trying to make [foo _ bar] read as (lambda (_) (foo _ bar)).
You can get something like `read-delimited-list' by using
`read/recursive' using #f to indicate the default readtable:
(define (read-square-brackets ch port src line col pos)
`(lambda ()
;; Recursive read starts with default readtable's [ parser,
;; but nested reads still use the curent readtable:
,(read/recursive port #\[ #f)))
(parameterize ([current-readtable
(make-readtable #f
#\[ 'terminating-macro read-square-brackets)])
(read (open-input-string "[foo _ bar]")))
Matthew