-
Notifications
You must be signed in to change notification settings - Fork 32
ConformanceModes
Larceny offers these three modes of execution, as selected by command-line arguments:
-
R7RS-conforming: libraries, programs, and read/eval/print loops behave as specified by the R7RS standard
-
R6RS-compatible: runs any reasonable R6RS-conforming program that doesn't raise a violation exception
-
R5RS-conforming: Larceny's traditional read/eval/print loop with many R7RS and R6RS extensions
In Larceny's R7RS-conforming mode, R6RS Scheme becomes a proper subset of R7RS Scheme. R7RS programmers can use R6RS syntax and libraries interchangeably with R7RS syntax and libraries. All standard libraries of the R7RS and R6RS can be imported in any combination without renaming identifiers.
The R6RS standard forbids extensions, and contains "absolute requirements" that forbid read/eval/print loops, so Larceny's R6RS-compatible mode is limited to running R6RS programs in batch mode. In Larceny, of course, every R6RS program is also an R7RS program that could be run in R7RS-conforming mode. There is only one reason to use R6RS-compatible mode: Its strict enforcement of the more limited R6RS syntax and semantics will detect and punish programs that attempt to use non-R6RS features of the R7RS.
Larceny's R5RS-conforming mode supports legacy code and provides the foundation for Larceny's implementation of the R7RS.
The recent R7RS standard unifies the traditional semantics of interactive read/eval/print loops with the library-centric semantics and features available to R6RS-style batch programs.
Larceny's R7RS-conforming mode is entered when Larceny is called in one of the following ways:
larceny -r7rs
larceny -r7rs -program filename
larceny -r7rs < filename
Larceny's R6RS-compatible mode can run R6RS-conforming programs in batch mode. If you want an interactive read/eval/print loop that approximates R6RS semantics, then you want Larceny's R7RS-conforming mode.
Larceny's R6RS-compatible mode is entered when Larceny is called in either of the following ways:
larceny -r6rs -program filename
larceny -r6rs < filename
On Unix systems, Larceny's R6RS-compatible mode can also be entered via the scheme-script
that Larceny provides for executing Scheme scripts.
Larceny's R6RS-compatible mode is almost, but not quite, R6RS-conforming. The main reason it isn't fully R6RS-conformant is that it doesn't always raise a violation exception when the R6RS says it must. It raises most of those exceptions, however, and provides roughly the same level of memory safety as languages like Java and C#. Larceny's principal deviations from R6RS-conformance are:
-
Larceny does not conform to known errors in the R6RS.
-
Larceny does not enforce deliberate weaknesses and restrictions whose primary purpose is to justify additional features.
-
Larceny may not support all of the additional features whose primary purpose is to work around the deliberate weaknesses and restrictions of the R6RS. Such features, whether supported or not, will be classified as deprecated.
-
The R6RS specifies
letrec*
semantics for internal definitions, and also requires a violation exception to be raised if aletrec
orletrec*
restriction is violated. Absent a new flow analysis, enforcement of these new mandates is costly in time and/or space. R6RS programmers are unlikely to write code that deliberately violates theletrec
orletrec*
restriction. We will devote our time to the R7RS and practical improvements instead of this ill-considered mandate of the R6RS. -
Twobit normally rejects programs that contain apparent errors of certain kinds. In many programming situations, we believe it is better to reject such programs at compile time than to let them execute, but we also recognize there are situations in which the compiler should merely warn the programmer without rejecting the program altogether. We offer this choice via the
compile-despite-errors
compiler switch, but that switch is off by default even in R6RS-compatible mode.
This is Larceny's traditional mode of execution, which remains the default. It provides R5RS syntax and semantics (e.g. case-insensitivity as an option) while offering many R7RS and R6RS features as extensions or as options that can be selected via parameters and/or dynamic loading (e.g. case-sensitivity required, internal definitions are like letrec*
, the R6RS io system, all R7RS and R6RS data types).
Larceny's R5RS-conforming mode is entered when Larceny is called like this:
larceny -r5rs -foldcase
Omitting the -foldcase
option enters Larceny's default mode, which is case-sensitive but otherwise R5RS-conforming.