Commit | Line | Data |
---|---|---|
b2e72381 | 1 | ;;; srfi-31.scm --- special form for recursive evaluation |
e96f5a6e | 2 | |
e7350baf | 3 | ;; Copyright (C) 2004, 2006, 2012 Free Software Foundation, Inc. |
e96f5a6e RB |
4 | ;; |
5 | ;; This library is free software; you can redistribute it and/or | |
6 | ;; modify it under the terms of the GNU Lesser General Public | |
7 | ;; License as published by the Free Software Foundation; either | |
83ba2d37 | 8 | ;; version 3 of the License, or (at your option) any later version. |
e96f5a6e RB |
9 | ;; |
10 | ;; This library 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 GNU | |
13 | ;; Lesser General Public License for more details. | |
14 | ;; | |
15 | ;; You should have received a copy of the GNU Lesser General Public | |
16 | ;; License along with this library; if not, write to the Free Software | |
92205699 | 17 | ;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
e96f5a6e RB |
18 | |
19 | ;;; Original author: Rob Browning <rlb@defaultvalue.org> | |
20 | ||
21 | (define-module (srfi srfi-31) | |
e7350baf | 22 | #:export (rec)) |
e96f5a6e | 23 | |
edb6de0b MW |
24 | (cond-expand-provide (current-module) '(srfi-31)) |
25 | ||
e7350baf LC |
26 | (define-syntax rec |
27 | (syntax-rules () | |
28 | "Return the given object, defined in a lexical environment where | |
29 | NAME is bound to itself." | |
30 | ((_ (name . formals) body ...) ; procedure | |
31 | (letrec ((name (lambda formals body ...))) | |
32 | name)) | |
33 | ((_ name expr) ; arbitrary object | |
34 | (letrec ((name expr)) | |
35 | name)))) |