locations.scm 1000 B

12345678910111213141516171819202122232425262728293031323334
  1. ; Part of Scheme 48 1.9. See file COPYING for notices and license.
  2. ; Authors: Richard Kelsey, Jonathan Rees
  3. ; Locations
  4. (define location-rtd
  5. (make-record-type 'location '(id defined? contents)))
  6. (define-record-discloser location-rtd
  7. (lambda (l) `(location ,(location-id l))))
  8. (define make-undefined-location
  9. (let ((make (record-constructor location-rtd
  10. '(id defined? contents))))
  11. (lambda (id)
  12. (make id #f '*empty*))))
  13. (define location? (record-predicate location-rtd))
  14. (define location-id (record-accessor location-rtd 'id))
  15. (define set-location-id! (record-modifier location-rtd 'id))
  16. (define location-defined? (record-accessor location-rtd 'defined?))
  17. (define contents (record-accessor location-rtd 'contents))
  18. (define set-defined?! (record-modifier location-rtd 'defined?))
  19. (define (set-location-defined?! loc ?)
  20. (set-defined?! loc ?)
  21. (if (not ?)
  22. (set-contents! loc '*empty*)))
  23. (define set-contents! (record-modifier location-rtd 'contents))