From 02b582cef51b982e6fbb0487ea45ea2f56dde5bb Mon Sep 17 00:00:00 2001 From: Andy Wingo Date: Fri, 11 Jun 2010 00:13:12 +0200 Subject: [PATCH] comments in boot-9 * module/ice-9/boot-9.scm: Add some comments about the nature of properties. --- module/ice-9/boot-9.scm | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/module/ice-9/boot-9.scm b/module/ice-9/boot-9.scm index 7e4a05116..4540d8567 100644 --- a/module/ice-9/boot-9.scm +++ b/module/ice-9/boot-9.scm @@ -537,8 +537,16 @@ If there is no handler at all, Guile prints an error and then exits." ;;; {General Properties} ;;; -;; This is a more modern interface to properties. It will replace all -;; other property-like things eventually. +;; Properties are a lispy way to associate random info with random objects. +;; 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) (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 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) (let ((pair (assoc prop (symbol-pref sym)))) (and pair (cdr pair)))) -- 2.20.1