| 1 |
;;; Copyright (c) 2006, 2007 Abdulaziz Ghuloum and Kent Dybvig |
| 2 |
;;; |
| 3 |
;;; Permission is hereby granted, free of charge, to any person obtaining a |
| 4 |
;;; copy of this software and associated documentation files (the "Software"), |
| 5 |
;;; to deal in the Software without restriction, including without limitation |
| 6 |
;;; the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 7 |
;;; and/or sell copies of the Software, and to permit persons to whom the |
| 8 |
;;; Software is furnished to do so, subject to the following conditions: |
| 9 |
;;; |
| 10 |
;;; The above copyright notice and this permission notice shall be included in |
| 11 |
;;; all copies or substantial portions of the Software. |
| 12 |
;;; |
| 13 |
;;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 14 |
;;; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 15 |
;;; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 16 |
;;; THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 17 |
;;; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
| 18 |
;;; FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
| 19 |
;;; DEALINGS IN THE SOFTWARE. |
| 20 |
|
| 21 |
(library (psyntax config) |
| 22 |
(export if-wants-define-record if-wants-define-struct |
| 23 |
if-wants-case-lambda |
| 24 |
if-wants-letrec* if-wants-global-defines |
| 25 |
if-wants-library-letrec* |
| 26 |
base-of-interaction-library) |
| 27 |
(import (rnrs)) |
| 28 |
|
| 29 |
(define (base-of-interaction-library) '(ikarus)) |
| 30 |
|
| 31 |
(define-syntax define-option |
| 32 |
(syntax-rules () |
| 33 |
((_ name #t) |
| 34 |
(define-syntax name |
| 35 |
(syntax-rules () |
| 36 |
((_ sk fk) sk)))) |
| 37 |
((_ name #f) |
| 38 |
(define-syntax name |
| 39 |
(syntax-rules () |
| 40 |
((_ sk fk) fk)))))) |
| 41 |
|
| 42 |
|
| 43 |
(define-option if-wants-define-record #t) |
| 44 |
(define-option if-wants-define-struct #t) |
| 45 |
;;; define-record is an ikarus-specific extension. |
| 46 |
;;; should be disabled for all other implementations |
| 47 |
;;; the source is included to illustrate how |
| 48 |
;;; implementation-specific extensions can be added |
| 49 |
;;; to the expander |
| 50 |
|
| 51 |
(define-option if-wants-global-defines #f) |
| 52 |
;;; If the implementation requires that all global |
| 53 |
;;; variables be defined before they're set!ed, |
| 54 |
;;; then enabling this option causes the expander |
| 55 |
;;; to produce (define <global> '#f) for every |
| 56 |
;;; exported identifiers. If the option is disabled, |
| 57 |
;;; then the global definitions are suppressed. |
| 58 |
|
| 59 |
(define-option if-wants-case-lambda #t) |
| 60 |
;;; Implementations that support case-lambda natively |
| 61 |
;;; should have the next option enabled. Disabling |
| 62 |
;;; wants-case-lambda causes the expander to produce |
| 63 |
;;; ugly, inefficient, but correct code by expanding |
| 64 |
;;; case-lambda into explicit dispatch code. |
| 65 |
|
| 66 |
(define-option if-wants-letrec* #t) |
| 67 |
;;; If the implementation has built-in support for |
| 68 |
;;; efficient letrec* (ikarus, chez), then this option |
| 69 |
;;; should be enabled. Disabling the option expands |
| 70 |
;;; (letrec* ((lhs* rhs*) ...) body) into |
| 71 |
;;; (let ((lhs* #f) ...) (set! lhs* rhs*) ... body) |
| 72 |
|
| 73 |
(define-option if-wants-library-letrec* #t) |
| 74 |
|
| 75 |
) |