INSTANCE-PREDICATE and INSTANCE-OF? to "instance.scm".
;;; -*-Scheme-*-
;;;
-;;; $Id: class.scm,v 1.1 1997/06/04 06:08:13 cph Exp $
+;;; $Id: class.scm,v 1.2 1997/06/04 22:29:00 cph Exp $
;;;
-;;; Copyright (c) 1995-96 Massachusetts Institute of Technology
+;;; Copyright (c) 1995-97 Massachusetts Institute of Technology
;;;
;;; This material was developed by the Scheme project at the
;;; Massachusetts Institute of Technology, Department of Electrical
standard-generic-procedure-tag
<generic-procedure>)
-(define <class> (object-class <object>))
-
-(define (instance-predicate class)
- (guarantee-class class 'INSTANCE-PREDICATE)
- (lambda (object) (instance-of? object class)))
-
-(define (instance-of? object class)
- (and (subclass? (object-class object) class)
- #t))
\ No newline at end of file
+(define <class> (object-class <object>))
\ No newline at end of file
;;; -*-Scheme-*-
;;;
-;;; $Id: instance.scm,v 1.1 1997/06/04 06:08:35 cph Exp $
+;;; $Id: instance.scm,v 1.2 1997/06/04 22:28:54 cph Exp $
;;;
-;;; Copyright (c) 1995-96 Massachusetts Institute of Technology
+;;; Copyright (c) 1995-97 Massachusetts Institute of Technology
;;;
;;; This material was developed by the Scheme project at the
;;; Massachusetts Institute of Technology, Department of Electrical
(class? (dispatch-tag-contents (tagged-vector-tag object)))))
(define (instance-class instance)
- (dispatch-tag-contents (tagged-vector-tag instance)))
\ No newline at end of file
+ (dispatch-tag-contents (tagged-vector-tag instance)))
+
+(define (instance-predicate class)
+ (guarantee-class class 'INSTANCE-PREDICATE)
+ (let ((predicate (make-generic-procedure 1)))
+ (let ((add
+ (lambda (c v)
+ (add-method predicate
+ (make-method (list c) (lambda (object) object v))))))
+ (add <object> #f)
+ (add class #t))
+ predicate))
+
+(define (instance-of? object class)
+ (and (subclass? (object-class object) class)
+ #t))
\ No newline at end of file
#| -*-Scheme-*-
-$Id: sos.pkg,v 1.1 1997/06/04 06:09:57 cph Exp $
+$Id: sos.pkg,v 1.2 1997/06/04 22:28:49 cph Exp $
Copyright (c) 1995-97 Massachusetts Institute of Technology
class-slots
class?
dispatch-tag->class
- instance-of?
- instance-predicate
make-class
make-trivial-subclass
object-class
(export ()
instance-class
instance-constructor
+ instance-of?
+ instance-predicate
instance?))
(define-package (sos method)