Skip to content

Coalton readtable consumes everything from a stream w/o existing metadata #1708

@shirok

Description

@shirok

Related to #1706

This may be by design. However, if you want to read multiple sexpr from a stream, it may interferes it.

CL-USER> *readtable*
#<NAMED-READTABLE COALTON:COALTON {1200BC08C3}>
CL-USER> (with-input-from-string (s "(a)(b)") (list (read s nil nil) (read s nil nil)))
((A) NIL)

If I'm using Slime and I run :coalton/tests, I'm in this state.

This is because read-coalton-toplevel-open-paren copies the entire input; the input stram is exhausted when the first call of read returns.

        (t
         ;; no metadata, no file operation, therefore we are in a
         ;; repl: bind a source-string containing cloned input
         (let ((*source* (coalton-impl/source:make-source-string
                          (with-output-to-string (out)
                            (write-char #\( out)
                            (alexandria:copy-stream stream out))
                          :name "repl")))
           (with-open-stream (stream (source:source-stream *source*))
             (read-char stream)
             (maybe-read-coalton stream *source*))))))
  • If the Coalton readtable isn't supposed to be used when the program uses read other than reading Coalton source, this may be a non-issue. We need to figure out why Slime uses Coalton readtable while executing CL code, though.
  • If the Coalton readtable is supposed to be transparent (e.g. it should function just like normal readtable if auxiliary info isn't there), we may need to do something.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions