Skip to content

Commit

Permalink
generic.multi: Add "multi" decorator
Browse files Browse the repository at this point in the history
Use with `GENERIC:` to make sure it is a multi-generic.
  • Loading branch information
timor committed Apr 7, 2021
1 parent 4de9da9 commit 8df71a9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
5 changes: 2 additions & 3 deletions core/generic/multi/multi-tests.factor
Expand Up @@ -127,9 +127,8 @@ MM: foo ( x: float x: number -- x ) call-next-method ;
{ 42 } [ [ 1.1 1 foo ] compile-call ] unit-test

! Testing eql specializers
GENERIC: bar ( x x -- x )
! FIXME: need one MM: right now to turn this into multi-generic
MM: bar ( x: number -- x ) 2drop 43 ;
GENERIC: bar ( x x -- x ) multi
M: D( number ) bar 2drop 43 ;
M: D( fixnum ) bar 2drop 42 ;
M: D( \= fixnum ) bar 2drop 47 ;
M: D( \= fixnum float ) bar 2drop 66 ;
Expand Down
3 changes: 3 additions & 0 deletions core/generic/multi/multi.factor
Expand Up @@ -229,3 +229,6 @@ ERROR: empty-dispatch-spec seq ;
] with-definition ;

SYNTAX: MM: (MM:) define ;

! Use to turn a GENERIC: into a multi-combination when only using D( ) things
SYNTAX: multi last-word >multi-combination ;

0 comments on commit 8df71a9

Please sign in to comment.