create-on-use.scm 612 B

12345678910111213
  1. ;;; A simple object which creates slots as they are used. This
  2. ;;; demonstrates the use of the MESSAGE-NOT-UNDERSTOOD error message.
  3. ;;; Slots behave like value slots, and the accessors use a second
  4. ;;; argument as the "default value". If that is not given, (if #f #f)
  5. ;;; is used, which is usually not what is intended.
  6. (define-object create-on-use-object (*the-root-object*)
  7. ((message-not-understood self resend slot args)
  8. (self 'add-method-slot! slot (lambda (self resend . default)
  9. (if (pair? args)
  10. (car args))))
  11. (self slot)))