curried-definitions.scm 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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-syntax cdefine
  21. (syntax-rules ()
  22. ((_ (head . rest) body body* ...)
  23. (cdefine head
  24. (lambda rest body body* ...)))
  25. ((_ name val)
  26. (define name val))))
  27. (define-syntax cdefine*
  28. (syntax-rules ()
  29. ((_ (head . rest) body body* ...)
  30. (cdefine* head
  31. (lambda* rest body body* ...)))
  32. ((_ name val)
  33. (define* name val))))
  34. (define-syntax define-public
  35. (syntax-rules ()
  36. ((_ (head . rest) body body* ...)
  37. (define-public head
  38. (lambda rest body body* ...)))
  39. ((_ name val)
  40. (begin
  41. (define name val)
  42. (export name)))))