Re: Reader flags to indicate different kinds of files
Marc Nieper-Wißkirchen 27 May 2020 10:20 UTC
Am Mi., 27. Mai 2020 um 11:51 Uhr schrieb Lassi Kortela <xxxxxx@lassi.io>:
>
> > 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?
It just ensures that R6RS lexical and datum syntax is used, so this is
a perfectly legitimate use of a reader flag. (In Racket, it is
different, but this is a different language.)
> 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.
The identification of the purpose of a file (its "metadata") does not
necessarily have to be based on file contents.
> 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.
You can't for general data files; but specific data file formats will
most likely start with a specific form, which is disjoint to
define-library.