srfi-9.scm 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. ;;; Records
  2. ;;; Copyright (C) 2024 Igalia, S.L.
  3. ;;;
  4. ;;; Licensed under the Apache License, Version 2.0 (the "License");
  5. ;;; you may not use this file except in compliance with the License.
  6. ;;; You may obtain a copy of the License at
  7. ;;;
  8. ;;; http://www.apache.org/licenses/LICENSE-2.0
  9. ;;;
  10. ;;; Unless required by applicable law or agreed to in writing, software
  11. ;;; distributed under the License is distributed on an "AS IS" BASIS,
  12. ;;; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. ;;; See the License for the specific language governing permissions and
  14. ;;; limitations under the License.
  15. ;;; Commentary:
  16. ;;;
  17. ;;; Records.
  18. ;;;
  19. ;;; Code:
  20. (library (srfi srfi-9)
  21. (export define-record-type)
  22. (import (hoot syntax)
  23. (prefix (hoot records) hoot:))
  24. (define-syntax-rule (define-record-type rtd (constructor cfield ...)
  25. predicate
  26. (field . g&s) ...)
  27. (begin
  28. (hoot:define-record-type rtd (%constructor field ...)
  29. predicate
  30. (field . g&s) ...)
  31. (define constructor
  32. (let ((field #f) ...)
  33. (lambda (cfield ...)
  34. (%constructor field ...)))))))