On Fri, Mar 26, 2021 at 3:37 AM Marc Nieper-Wißkirchen <xxxxxx@nieper-wisskirchen.de> wrote:

one cannot implement `include-ci` with `read`.

I think it's correct to implement it as a property of the port being read from, though R7RS does not say so.  This is what Larceny and Chibi do.
 
This leads to the follow-up question: When all of Scheme is allowed, we need to specify the environment through an import set. This should happen at the beginning of the stream so that the structure would be similar to top-level programs.
 
Such a restriction is untenable in the presence of #.(include "foo.scm"), because foo.scm may have its own #. imports.  The stream as a whole must allow #.(import (this) (that)).

Alternatively, one can drop the multiple values but invent a "#xxxxxx@", which does list splicing.

I think it would be clearer and more Schemey to do this.
 
(define (read-delimited-list delim port)
  (let loop ((result '()))
    (cond
      ((whitespace? (peek-char port))
        (loop result))
      ((eqv? delim (peek-char port))
       (read-char port)    ; read past delim
       (reverse result)
      (else
        (loop (cons (read port) result)))))

Such a `read-delimited-list` that doesn't call recursively call `read` is unaware of other lexical syntax extensions. For example, it would break on an input like "[ #| ] |# ]".

It does call `read` recursively: see the last line.

Apart from that, `eval` allows dynamic importing of libraries. Either do the evaluation in the interaction environment, which usually allows `import` statements,

If it does, it is non-conforming.


PS We should also take a look at Racket's reader extensions, maybe to steal an idea or two. Their guide is very readable: https://docs.racket-lang.org/guide/languages.html.

It reads very much like Racket documentation: for insiders by insiders, and assuming a good deal of detailed knowledge I don't have.



John Cowan          http://vrici.lojban.org/~cowan        xxxxxx@ccil.org
With techies, I've generally found
If your arguments lose the first round
Make it rhyme, make it scan / Then you generally can
Make the same stupid point seem profound!           --Jonathan Robie