Skip to content

Commit

Permalink
classes.dispatch: Add word for checking class participation
Browse files Browse the repository at this point in the history
Used to determine whether a dispatch specifier depends on a specific class.
Used for dependency checking.
  • Loading branch information
timor committed Apr 15, 2021
1 parent 88b06e3 commit 5e71cfd
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 0 deletions.
3 changes: 3 additions & 0 deletions core/classes/dispatch/class/class.factor
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,6 @@ M: class-specializer (classes-intersect?)

M: class-specializer add-depends-on-class
class>> add-depends-on-class ;

M: class-specializer dispatch-depends-on?
class>> class= ;
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,6 @@ M: covariant-tuple dispatch-predicate-def
[ 1 + swap '{ [ _ npick _ instance? not ] [ f ] } ] map-index
[ t ] suffix
'[ _ cond ] ;

M: covariant-tuple dispatch-depends-on?
classes>> member? ;
3 changes: 3 additions & 0 deletions core/classes/dispatch/dispatch.factor
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,6 @@ GENERIC: dispatch-arity ( dispatch-type -- n )
! type at index.
GENERIC: nth-dispatch-applicable? ( class index dispatch-type -- ? )
GENERIC: dispatch-predicate-def ( dispatch-type -- quot )

! Return whether the dispatch specifier depends on the given class
GENERIC: dispatch-depends-on? ( class dispatch-type -- ? )
3 changes: 3 additions & 0 deletions core/classes/dispatch/eql/eql.factor
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,6 @@ M: eql-specializer left-dispatch<=
M: eql-specializer (classes-intersect?)
{ { [ over eql-specializer? ] [ [ obj>> ] same? ] }
[ obj>> class-of classes-intersect? ] } cond ;

M: eql-specializer dispatch-depends-on?
obj>> class-of class= ;

0 comments on commit 5e71cfd

Please sign in to comment.