Come to think of it, since Scheme has a separate metalevel for
`define-library`, how come there isn't a general `#!meta` read flag?
That would obviate the need for the separate `.sld` filename extension
as well.
Because there is no distinction at the lexical syntax level between R7RS code files and R7RS library definitions. Larceny supports a variety of such flags: #r5rs, #r6rs, #err5rs, #r7rs, and #larceny. Everything else depends on what libraries are loaded.
Maybe it's because the separate metalevel is not a required part of
R7RS, but just one implementation strategy?
Depends on what you mean by "separate". The contents of a define-library form are not Scheme but a DSL, whereas the contents of a library form are an export form followed by an import form followed by Scheme. This is quite independent iof whether define-library forms and other forms can be entered at the REPL or concatenated with code into a single file. In Chibi neither the REPL nor a code file can understand define-library; in Chicken's R7RS mode, define-library is valid in both places. The meaning of identifiers is not affected by these lexical syntax flags; that is controlled by what libraries
The most important distinction in this respect is how library names are mapped to filenames:
In Chibi, (import (foo bar)) looks (in each directory on the path) for foo/bar.sld.
In Guile, (import (foo bar)) looks for foo/bar.scm or (if R6RS mode has been enabled with (install-r6rs!) foo/bar.sls or foo/bar.guile.sls.
In Ypsilon, (import (foo bar)) looks for foo/bar.sls or .ss or .scm, or any of these preceded by ypsilon.
In Chicken, (import (foo bar)) looks for foo.bar.scm.
So what I usually do is to put the code file of a SRFI into foo/bar-impl.scm (or foo/*.scm if there is more than one) and plant the library files where they need to be for the above Schemes. (I provide a trivial (include) library for use by R6RS library files.) That way, all implementation-specific shim or differently-named libraries appear in the library definition files, perhaps by cond-expand in some cases.
By the way, I don't agree that there is such a thing as *the* purpose of a file. Files can be, and often are, used for more than one purpose.