This site is a static rendering of the Trac instance that was used by R7RS-WG1 for its work on R7RS-small (PDF), which was ratified in 2013. For more information, see Home.

Ticket 521: Make library contents be at top level

2013-07-07 03:20:44
WG1 - Core
alexshinn
major
cowan
wontfix
source
closed
2013-05-13 16:26:43
defect

Mikael More writes:

Problem: The Library syntax requires all library content to be put within the define-library form (there in a begin or include*). This means that to define a library, the programmer is reasonably required to either put all library code in a define-library and also indent accordingly, or maintain two files per library.

Rationale: An incremental development situation makes use of any convenience as to increase the speed of experimentation. In such a situation, creating two files per library would seem completely unjustified. Also, in general Scheme development, Scheme can be made to work reliably without need for separation of a library into anything like a separate header and code file. By this reason, I will not consider the two files per library use-case further here but focus on the other point:

I find a requirement that >99% of the Scheme code in existence needing to be made within a particular form and indented accordingly peculiar indeed. The way Scheme code traditionally is divided into files works so well that I believe a specific define-library form in addition to this to contain the library, to be superfluous. And, Scheme's traditional forms provide sufficient structure to perform indentation based on.

Suggestion: Please find a way so that the library body in the library definition file is at the top level.

One way would be to allow a variant of define-library of 5.6.1. to be used as (define-library (library name)) and then provide the library declarations subsequent to this one, with the exception of the begin library declaration whose contents are inlined by themselves.

I'd guess many times the Scheme file's filename would provide the information otherwise provided by (define-library (library name)) , so that that line could be made optional generally also.

In response to the last point only: Both Chibi and most R6RS Schemes use the approach of having a library-path to specify the directories which are the roots of the library system. Without an explicit name associated with the library, changing the root would implicitly change the name.

My experience (which as I said is still very limited) is that the modest discipline imposed by the two-file solution has surprising advantages. For one thing, it provides superior delivery to the various kinds of Scheme implementations out there to have one or more files of code supplemented by a library-declaration file whose form depends on the system it is to be used for.

Thus, I can deliver a library foo for both Chibi and Chicken (my two platforms of choice) by providing a foo-impl.scm file containing pure R5RS-ish code and two files that include it: a foo.scm file that takes the form of a Chicken module declaration, and a foo.sld file that takes the form of an R7RS library declaration. I could easily add various foo.*.sls files for R6RS systems if I wanted to. Furthermore, an implementation of Scheme that lacks modules can just load foo-impl.scm and ignore all the library junk. Note that no additional indentation exists within the foo-impl.scm file.

In addition, while debugging I often want access to the private (non-exported) functions of the library: see my comment on #520 for why there often are such functions. By using load at the REPL to load the foo-impl.scm file rather than some version of import (in Chicken, use), I get access to the private functions from the REPL without having to touch the export declarations.

As was pointed out on the list, it's easy to change your identer not to ident the contents of define-library forms.

resolutionwontfix
statusnewclosed

The WG decided by unanimous consent to take no action on this ticket.