srfi-31.scm 1.4 KB

123456789101112131415161718192021222324252627282930313233343536
  1. ;;; srfi-31.scm --- special form for recursive evaluation
  2. ;; Copyright (C) 2004, 2006, 2012 Free Software Foundation, Inc.
  3. ;;
  4. ;; This library is free software; you can redistribute it and/or
  5. ;; modify it under the terms of the GNU Lesser General Public
  6. ;; License as published by the Free Software Foundation; either
  7. ;; version 3 of the License, or (at your option) any later version.
  8. ;;
  9. ;; This library is distributed in the hope that it will be useful,
  10. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. ;; Lesser General Public License for more details.
  13. ;;
  14. ;; You should have received a copy of the GNU Lesser General Public
  15. ;; License along with this library; if not, write to the Free Software
  16. ;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  17. ;;; Original author: Rob Browning <rlb@defaultvalue.org>
  18. (define-module (srfi srfi-31)
  19. #:export (rec))
  20. (cond-expand-provide (current-module) '(srfi-31))
  21. (define-syntax rec
  22. (syntax-rules ()
  23. "Return the given object, defined in a lexical environment where
  24. NAME is bound to itself."
  25. ((_ (name . formals) body ...) ; procedure
  26. (letrec ((name (lambda formals body ...)))
  27. name))
  28. ((_ name expr) ; arbitrary object
  29. (letrec ((name expr))
  30. name))))