Re: Reader flags to indicate different kinds of files
Lassi Kortela 27 May 2020 09:51 UTC
> I'd say keep separate things separate. Reader flags should affect how
> things are read by `read' procedure (and the Scheme reader) and should
> not be (mis)used for anything else. A reader flag for different Scheme
> dialects is fine as long as it switches the reader into the
> appropriate mode, but the flag itself should not communicate any
> meaning of the underlying Scheme data.
This is a good principle, but it may have been been broken already.
`#!r6rs` switches to R6RS read syntax, but does it also switch to R6RS
definitions and language semantics?
If we don't use `#!` to identify the purpose of a file we should have
some other way to do so. The proposed `(declare-file ...)` as the first
S-expression in a file would do that, but it's not without its problems
as well. Since we are retrofitting these things into Scheme, there is no
100% perfect solution.
> This is up to the Scheme data itself. For example, R7RS library
> definitions start with a define-library form, R6RS library definitions
> with a library form, top-level programs with an import form, etc.
This is reasonable. You still can't reliably differentiate a data file
meant to be read in as quoted S-expressions (where the first such
S-expression happens to be a `(define-library ...)` form) from files
meant to be evaluated. But maybe it's not that important.