(define predicate?)
(define register-predicate!)
-(let ((predicates '()))
+(define predicate->dispatch-tag)
+(define set-predicate-tag!)
+(let ((predicates '())
+ (associations '()))
(set! predicate?
(lambda (object)
- (if (memq object predicates) #t #f)))
+ (if (or (memq object predicates)
+ (assq object associations))
+ #t
+ #f)))
(set! register-predicate!
(lambda (predicate name . keylist)
(defer-boot-action 'predicate-registrations
(apply register-predicate! predicate name keylist)))
(set! predicates (cons predicate predicates))
unspecific))
+ (set! predicate->dispatch-tag
+ (lambda (predicate)
+ (cdr (assq predicate associations))))
+ (set! set-predicate-tag!
+ (lambda (predicate tag)
+ (set! associations (cons (cons predicate tag) associations))
+ (defer-boot-action 'set-predicate-tag!
+ (lambda ()
+ (set-predicate-tag! predicate tag)))))
unspecific)
(define (set-dispatch-tag<=! t1 t2)
(lambda (port)
(write-string "object satisfying " port)
(write predicate port)))))
-
+\f
;;;; Miscellany
(define (object-constant? object)
(cdr object)))))
(register-predicate! tag-name? 'dispatch-tag-name)
-(define (set-predicate-tag! predicate tag)
- (defer-boot-action 'set-predicate-tag!
- (lambda ()
- (set-predicate-tag! predicate tag))))
-
(define (dispatch-tag? object)
(and (%record? object)
(dispatch-metatag? (%record-ref object 0))))
(define (dispatch-metatag? object)
(and (%record? object)
(eq? metatag-tag (%record-ref object 0))))
+(set-predicate<=! dispatch-metatag? dispatch-tag?)
(define metatag-tag)
(add-boot-init!
(lambda ()
(set! metatag-tag (%make-tag #f 'metatag dispatch-metatag? '#()))
(%record-set! metatag-tag 0 metatag-tag)))
-\f
+
(define (dispatch-tag-metatag tag)
(guarantee dispatch-tag? tag 'dispatch-tag-metatag)
(%record-ref tag 0))
(guarantee dispatch-tag? superset 'add-dispatch-tag-superset)
(%add-to-weak-set superset (%tag-supersets tag)))
-(defer-boot-action 'predicate-relations
- (lambda ()
- (set-predicate<=! dispatch-metatag? dispatch-tag?)))
-
(define-unparser-method dispatch-tag?
(simple-unparser-method
(lambda (tag)
(declare (usual-integrations))
\f
-(define (predicate->dispatch-tag predicate)
- (let ((tag (get-predicate-tag predicate #f)))
- (if (not tag)
- (error:not-a predicate? predicate))
- tag))
-
(define (predicate-name predicate)
(dispatch-tag-name (predicate->dispatch-tag predicate)))
(let ((table (make-hashed-metadata-table)))
(set! predicate? (table 'has?))
(set! get-predicate-tag (table 'get))
- (set! set-predicate-tag! (table 'put!))
- (run-deferred-boot-actions 'set-predicate-tag!))
+ (set! set-predicate-tag! (table 'put!)))
+ (set! predicate->dispatch-tag
+ (named-lambda (predicate->dispatch-tag predicate)
+ (let ((tag (get-predicate-tag predicate #f)))
+ (if (not tag)
+ (error:not-a predicate? predicate))
+ tag)))
+ (run-deferred-boot-actions 'set-predicate-tag!)
(set! register-predicate!
(let ((make-simple-tag
(dispatch-metatag-constructor
interrupt-mask/timer-ok
object-constant?
object-pure?
+ predicate->dispatch-tag
predicate?
register-predicate!
set-dispatch-tag<=!
add-boot-init!
defer-boot-action
run-deferred-boot-actions)
+ (export (runtime predicate)
+ set-predicate-tag!)
(export (runtime rep)
- finished-booting!))
+ finished-booting!)
+ (export (runtime tagged-dispatch)
+ set-predicate-tag!))
(define-package (runtime equality)
(files "equals")
dispatch-tag=
dispatch-tag>=
no-object?
- predicate->dispatch-tag
predicate-name
predicate<=
predicate>=
make-dispatch-metatag)
(export (runtime predicate)
add-dispatch-tag-superset
- any-dispatch-tag-superset
- set-predicate-tag!))
+ any-dispatch-tag-superset))
(define-package (runtime crypto)
(files "crypto")