-;;; Like ANY and EVERY, except that we handle two-arg uncertain predicates.
-;;; If the result is uncertain, then we return Default from the block PUNT.
-;;; If LIST-FIRST is true, then the list element is the first arg, otherwise
-;;; the second.
-(defmacro any-type-op (op thing list &key (default '(values nil nil))
- list-first)
- (let ((n-this (gensym))
- (n-thing (gensym))
- (n-val (gensym))
- (n-win (gensym))
- (n-uncertain (gensym)))
- `(let ((,n-thing ,thing)
- (,n-uncertain nil))
- (dolist (,n-this ,list
- (if ,n-uncertain
- (return-from punt-type-method ,default)
- nil))
- (multiple-value-bind (,n-val ,n-win)
- ,(if list-first
- `(,op ,n-this ,n-thing)
- `(,op ,n-thing ,n-this))
- (unless ,n-win (setq ,n-uncertain t))
- (when ,n-val (return t)))))))
-(defmacro every-type-op (op thing list &key (default '(values nil nil))
- list-first)
- (let ((n-this (gensym))
- (n-thing (gensym))
- (n-val (gensym))
- (n-win (gensym)))
- `(let ((,n-thing ,thing))
- (dolist (,n-this ,list t)
- (multiple-value-bind (,n-val ,n-win)
- ,(if list-first
- `(,op ,n-this ,n-thing)
- `(,op ,n-thing ,n-this))
- (unless ,n-win (return-from punt-type-method ,default))
- (unless ,n-val (return nil)))))))
-
-;;; Compute the intersection for types that intersect only when one is a
-;;; hierarchical subtype of the other.
-(defun vanilla-intersection (type1 type2)
- (multiple-value-bind (stp1 win1) (csubtypep type1 type2)
- (multiple-value-bind (stp2 win2) (csubtypep type2 type1)
- (cond (stp1 (values type1 t))
- (stp2 (values type2 t))
- ((and win1 win2) (values *empty-type* t))
- (t
- (values type1 nil))))))
-
-(defun vanilla-union (type1 type2)
+;;; Look for nice relationships for types that have nice relationships
+;;; only when one is a hierarchical subtype of the other.
+(defun hierarchical-intersection2 (type1 type2)
+ (multiple-value-bind (subtypep1 win1) (csubtypep type1 type2)
+ (multiple-value-bind (subtypep2 win2) (csubtypep type2 type1)
+ (cond (subtypep1 type1)
+ (subtypep2 type2)
+ ((and win1 win2) *empty-type*)
+ (t nil)))))
+(defun hierarchical-union2 (type1 type2)