Commit | Line | Data |
---|---|---|
344927c3 DK |
1 | ;;; Guile Emac Lisp |
2 | ||
3 | ;; Copyright (C) 2001 Free Software Foundation, Inc. | |
4 | ||
5 | ;; This program is free software; you can redistribute it and/or modify | |
6 | ;; it under the terms of the GNU General Public License as published by | |
7 | ;; the Free Software Foundation; either version 2, or (at your option) | |
8 | ;; any later version. | |
9 | ;; | |
10 | ;; This program is distributed in the hope that it will be useful, | |
11 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | ;; GNU General Public License for more details. | |
14 | ;; | |
15 | ;; You should have received a copy of the GNU General Public License | |
16 | ;; along with this program; see the file COPYING. If not, write to | |
17 | ;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
18 | ;; Boston, MA 02111-1307, USA. | |
19 | ||
20 | ;;; Code: | |
21 | ||
22 | (define-module (language elisp runtime) | |
f614ca12 DK |
23 | #:export (void nil-value t-value elisp-bool runtime-error macro-error) |
24 | #:export-syntax (built-in-func built-in-macro prim)) | |
344927c3 DK |
25 | |
26 | ; This module provides runtime support for the Elisp front-end. | |
27 | ||
1e018f6c | 28 | |
344927c3 | 29 | ; The reserved value to mean (when eq?) void. |
1e018f6c | 30 | |
344927c3 | 31 | (define void (list 42)) |
1e018f6c DK |
32 | |
33 | ||
34 | ; Values for t and nil. | |
35 | ||
36 | ; FIXME: Use real nil. | |
37 | (define nil-value #f) | |
38 | (define t-value #t) | |
39 | ||
40 | ||
7d1a9782 | 41 | ; Report an error during macro compilation, that means some special compilation |
f614ca12 | 42 | ; (syntax) error; or report a simple runtime-error from a built-in function. |
7d1a9782 DK |
43 | |
44 | (define (macro-error msg . args) | |
45 | (apply error msg args)) | |
46 | ||
f614ca12 DK |
47 | (define runtime-error macro-error) |
48 | ||
7d1a9782 | 49 | |
1e018f6c DK |
50 | ; Convert a scheme boolean to Elisp. |
51 | ||
52 | (define (elisp-bool b) | |
53 | (if b | |
54 | t-value | |
55 | nil-value)) | |
56 | ||
57 | ||
7d1a9782 DK |
58 | ; Define a predefined function or predefined macro for use in the function-slot |
59 | ; and macro-slot modules, respectively. | |
60 | ||
61 | (define-syntax built-in-func | |
62 | (syntax-rules () | |
63 | ((_ name value) | |
64 | (begin | |
65 | (define-public name (make-fluid)) | |
66 | (fluid-set! name value))))) | |
1e018f6c | 67 | |
7d1a9782 DK |
68 | (define-syntax built-in-macro |
69 | (syntax-rules () | |
70 | ((_ name value) | |
71 | (define-public name value)))) | |
f614ca12 DK |
72 | |
73 | ||
74 | ; Call a guile-primitive that may be rebound for elisp and thus needs absolute | |
75 | ; addressing. | |
76 | ||
77 | (define-syntax prim | |
78 | (syntax-rules () | |
79 | ((_ sym args ...) | |
80 | ((@ (guile) sym) args ...)))) |