schemelispguile

How to read only one expression at a time in Guile Scheme


I am trying to make a reader extension in Guile Scheme. When writing this reader extension, I would like to use a guile function that reads in only one expression at a time, like read-expression and read-sexp, but these functions do not appear to be available in the default namespace. I am unable to find documentation on these functions, so I do not know what modules to import to use them. I know they are implemented in the Guile source code (in read.c), as scm_read_expression and scm_read_sexp respectively. I had been assuming that these functions are exposed to some Scheme API, hence the "scm_" prefix... Is that assumption valid? Either way, are there functions available in some Guile module that would allow me to read in only a single expression at a time?


Solution

  • When asking this question, I mistakenly believed that read would read all the expressions in the given port. In fact, read only reads in one expression, and so has the behavior needed for my purposes. See the manual entry here: https://www.gnu.org/software/guile/manual/html_node/Scheme-Read.html