Notes on writing portable Scheme code. Generally speaking, the R5RS describes everything on which you can rely in portable Scheme code. For the purposes of CS G262, you may also rely on the following, even though these things are not implied by the R5RS: * All non-negative integers less than (expt 2 32) have representations as exact integers. * If m and n are exact integers, and (<= 0 m (expt 2 32)) and (<= 0 n (expt 2 32)), then (- m n) is an exact integer. * Inexact real numbers are supported, and inexact real arithmetic behaves more or less as in IEEE Std 754. Please remember that portable Scheme code cannot rely on the following: * SRFIs * SYNTAX-CASE * Records, object systems, and so on. * Formatted i/o. * Specific character encodings. * Square brackets as alternatives to parentheses. If you can find a portable implementation of such a feature, then you may include that implementation in your code, with proper acknowledgement, and use that feature in your code. Here are notes on how to run several popular implementations in their maximally R5RS-compliant modes, including notes on several portability problems (such as the representations written by WRITE) that are caused by underspecification in the R5RS itself, and are thus unrelated to R5RS-compliance. The author of each note is named in parentheses. **************************************************************** Bigloo (Manuel Serrano): Concerning Bigloo, compile your modules with -call/cc. The module clause, of course, is not R5Rs compliant. The solution I generally use is to split the module in two files: - one file containing the Bigloo module clause - one file containing the r5rs source code **************************************************************** Chez (Kent Dybvig): For Chez Scheme or Petite Chez Scheme, you want the following settings: (print-brackets #f) (print-vector-length #f) ....The only way to get Chez Scheme's write procedure to print mixed-case symbols without escape characters (display already does so) is to set the case-sensitive parameter to true while printing, e.g.: (define write (lambda args (parameterize ((case-sensitive #t)) (apply (let () (import scheme) write) args)))) This will print the symbols in mixed case but without escape characters. If you want all one case, that's a bit more difficult but still doable. If you want your students to evaluate code in the r5rs environment, have them download Version 6.9c from www.scheme.com, since prior to Version 6.9c, some of the c...r variable bindings were left out of the r5rs environment by mistake. **************************************************************** Gambit (Marc Feeley): In Gambit-C 3.0 you must run the interpreter with the -:s switch (s=standard) to get case-insensitivity, i.e. gsi -:s Gambit-C 3.0 is not R5RS compliant because it does not include syntax-rules. However, there is a file on the Gambit web page that you can "load" into Gambit to provide syntax-rules (and syntax-case). You can automate this process by putting the "load" in the Gambit initialization file. **************************************************************** Larceny (Will Clinger): On behalf of Larceny v0.50, I'll report that its maximally R5RS-compliant mode is obtained by evaluating (compiler-switches 'standard). **************************************************************** PLT Scheme/MzScheme/MrEd/DrScheme (Matthew Flatt): As of v208, `letrec' in MzScheme/MrEd/DrScheme is still broken, because it's implemented as `letrec*'. I think that's the only bug on the input side. > * case-sensitivity > * nonstandard escape characters (e.g. vertical bars) being printed > for symbols of mixed case that are created by STRING->SYMBOL > * nonstandard printing of vectors, e.g. #3(a b c) instead of #(a b c) > * nonstandard printing of lists, e.g. square brackets instead of > parens when printing lists that look like Scheme code MzScheme/MrEd/DrScheme have the problem with non-standard escape and vector lengths. They can be disabled dynamically with (read-accept-bar-quote #f) (print-vector-length #f) I can't think of anything else that's broken (nothing else relevant is in the list of read/print-control parameters), but I didn't think of these before, either. **************************************************************** Scheme 48 (Mike Sperber): For Scheme 48, [the maximally R5RS-compliant mode is obtained by typing] scheme48 ****************************************************************