curried-definitions.scm 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. ;;; Copyright (C) 2010, 2013 Free Software Foundation, Inc.
  2. ;;;
  3. ;;;; This library is free software; you can redistribute it and/or
  4. ;;;; modify it under the terms of the GNU Lesser General Public
  5. ;;;; License as published by the Free Software Foundation; either
  6. ;;;; version 3 of the License, or (at your option) any later version.
  7. ;;;;
  8. ;;;; This library is distributed in the hope that it will be useful,
  9. ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. ;;;; Lesser General Public License for more details.
  12. ;;;;
  13. ;;;; You should have received a copy of the GNU Lesser General Public
  14. ;;;; License along with this library; if not, write to the Free Software
  15. ;;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  16. (define-module (ice-9 curried-definitions)
  17. #:replace ((cdefine . define)
  18. (cdefine* . define*)
  19. define-public
  20. define*-public))
  21. (define-syntax cdefine
  22. (syntax-rules ()
  23. ((_ (head . rest) body body* ...)
  24. (cdefine head
  25. (lambda rest body body* ...)))
  26. ((_ name val)
  27. (define name val))))
  28. (define-syntax cdefine*
  29. (syntax-rules ()
  30. ((_ (head . rest) body body* ...)
  31. (cdefine* head
  32. (lambda* rest body body* ...)))
  33. ((_ name val)
  34. (define* name val))))
  35. (define-syntax define-public
  36. (syntax-rules ()
  37. ((_ (head . rest) body body* ...)
  38. (define-public head
  39. (lambda rest body body* ...)))
  40. ((_ name val)
  41. (begin
  42. (define name val)
  43. (export name)))))
  44. (define-syntax define*-public
  45. (syntax-rules ()
  46. ((_ (head . rest) body body* ...)
  47. (define*-public head
  48. (lambda* rest body body* ...)))
  49. ((_ name val)
  50. (begin
  51. (define* name val)
  52. (export name)))))