1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-04-30 11:50:28 +02:00

comments in boot-9

* module/ice-9/boot-9.scm: Add some comments about the nature of
  properties.
This commit is contained in:
Andy Wingo 2010-06-11 00:13:12 +02:00
parent 0f509ab5e3
commit 02b582cef5

View file

@ -537,8 +537,16 @@ If there is no handler at all, Guile prints an error and then exits."
;;; {General Properties} ;;; {General Properties}
;;; ;;;
;; This is a more modern interface to properties. It will replace all ;; Properties are a lispy way to associate random info with random objects.
;; other property-like things eventually. ;; Traditionally properties are implemented as an alist or a plist actually
;; pertaining to the object in question.
;;
;; These "object properties" have the advantage that they can be associated with
;; any object, even if the object has no plist. Object properties are good when
;; you are extending pre-existing objects in unexpected ways. They also present
;; a pleasing, uniform procedure-with-setter interface. But if you have a data
;; type that always has properties, it's often still best to store those
;; properties within the object itself.
(define (make-object-property) (define (make-object-property)
(let ((prop (primitive-make-property #f))) (let ((prop (primitive-make-property #f)))
@ -551,6 +559,10 @@ If there is no handler at all, Guile prints an error and then exits."
;;; {Symbol Properties} ;;; {Symbol Properties}
;;; ;;;
;;; Symbol properties are something you see in old Lisp code. In most current
;;; Guile code, symbols are not used as a data structure -- they are used as
;;; keys into other data structures.
(define (symbol-property sym prop) (define (symbol-property sym prop)
(let ((pair (assoc prop (symbol-pref sym)))) (let ((pair (assoc prop (symbol-pref sym))))
(and pair (cdr pair)))) (and pair (cdr pair))))