diff --git a/module/ice-9/psyntax-pp.scm b/module/ice-9/psyntax-pp.scm index 90fbb644c..4e0a3e598 100644 --- a/module/ice-9/psyntax-pp.scm +++ b/module/ice-9/psyntax-pp.scm @@ -30,10 +30,8 @@ (#{first\ 231}# (cdr #{first\ 223}#)) (#{rest\ 232}# (map cdr #{rest\ 224}#))) (if (null? #{first\ 231}#) - (@apply #{f\ 199}# (cons #{x\ 229}# #{xr\ 230}#)) - (if (@apply - #{f\ 199}# - (cons #{x\ 229}# #{xr\ 230}#)) + (@apply #{f\ 199}# #{x\ 229}# #{xr\ 230}#) + (if (@apply #{f\ 199}# #{x\ 229}# #{xr\ 230}#) (#{andmap\ 222}# #{first\ 231}# #{rest\ 232}#) #f))))))) (begin diff --git a/module/ice-9/psyntax.scm b/module/ice-9/psyntax.scm index 0d0025f19..34efa2b0f 100644 --- a/module/ice-9/psyntax.scm +++ b/module/ice-9/psyntax.scm @@ -19,17 +19,9 @@ ;;; Portable implementation of syntax-case -;;; Extracted from Chez Scheme Version 5.9f +;;; Originally extracted from Chez Scheme Version 5.9f ;;; Authors: R. Kent Dybvig, Oscar Waddell, Bob Hieb, Carl Bruggeman -;;; Modified by Andy Wingo according to the Git -;;; revision control logs corresponding to this file: 2009, 2010. - -;;; Modified by Mikael Djurfeldt according -;;; to the ChangeLog distributed in the same directory as this file: -;;; 1997-08-19, 1997-09-03, 1997-09-10, 2000-08-13, 2000-08-24, -;;; 2000-09-12, 2001-03-08 - ;;; Copyright (c) 1992-1997 Cadence Research Systems ;;; Permission to copy this software, in whole or in part, to use this ;;; software for any lawful purpose, and to redistribute this software @@ -41,15 +33,20 @@ ;;; AUTHORS BE LIABLE FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES OF ANY ;;; NATURE WHATSOEVER. -;;; Before attempting to port this code to a new implementation of -;;; Scheme, please read the notes below carefully. +;;; Modified by Mikael Djurfeldt according +;;; to the ChangeLog distributed in the same directory as this file: +;;; 1997-08-19, 1997-09-03, 1997-09-10, 2000-08-13, 2000-08-24, +;;; 2000-09-12, 2001-03-08 + +;;; Modified by Andy Wingo according to the Git +;;; revision control logs corresponding to this file: 2009, 2010. ;;; This file defines the syntax-case expander, macroexpand, and a set ;;; of associated syntactic forms and procedures. Of these, the ;;; following are documented in The Scheme Programming Language, -;;; Second Edition (R. Kent Dybvig, Prentice Hall, 1996). Most are -;;; also documented in the R4RS and draft R5RS. +;;; Fourth Edition (R. Kent Dybvig, MIT Press, 2009), and in the +;;; R6RS: ;;; ;;; bound-identifier=? ;;; datum->syntax @@ -67,9 +64,8 @@ ;;; syntax-rules ;;; with-syntax ;;; -;;; All standard Scheme syntactic forms are supported by the expander -;;; or syntactic abstractions defined in this file. Only the R4RS -;;; delay is omitted, since its expansion is implementation-dependent. +;;; Additionally, the expander provides definitions for a number of core +;;; Scheme syntactic bindings, such as `let', `lambda', and the like. ;;; The remaining exports are listed below: ;;; @@ -87,83 +83,40 @@ ;;; ($sc-dispatch e p) ;;; used by expanded code to handle syntax-case matching -;;; The following nonstandard procedures must be provided by the -;;; implementation for this code to run using the standard portable -;;; hooks and output constructors. They are not used by expanded code, -;;; and so need be present only at expansion time. +;;; This file is shipped along with an expanded version of itself, +;;; psyntax-pp.scm, which is loaded when psyntax.scm has not yet been +;;; compiled. In this way, psyntax bootstraps off of an expanded +;;; version of itself. + +;;; This implementation of the expander sometimes uses syntactic +;;; abstractions when procedural abstractions would suffice. For +;;; example, we define top-wrap and top-marked? as ;;; -;;; (eval x) -;;; where x is always in the form ("noexpand" expr). -;;; returns the value of expr. the "noexpand" flag is used to tell the -;;; evaluator/expander that no expansion is necessary, since expr has -;;; already been fully expanded to core forms. -;;; -;;; eval will not be invoked during the loading of psyntax.pp. After -;;; psyntax.pp has been loaded, the expansion of any macro definition, -;;; whether local or global, will result in a call to eval. If, however, -;;; macroexpand has already been registered as the expander to be used -;;; by eval, and eval accepts one argument, nothing special must be done -;;; to support the "noexpand" flag, since it is handled by macroexpand. -;;; -;;; (gensym) -;;; returns a unique symbol each time it's called - -;;; When porting to a new Scheme implementation, you should define the -;;; procedures listed above, load the expanded version of psyntax.ss -;;; (psyntax.pp, which should be available whereever you found -;;; psyntax.ss), and register macroexpand as the current expander (how -;;; you do this depends upon your implementation of Scheme). You may -;;; change the hooks and constructors defined toward the beginning of -;;; the code below, but to avoid bootstrapping problems, do so only -;;; after you have a working version of the expander. - -;;; Chez Scheme allows the syntactic form (syntax