On Dec 24, 2010, at 7:32 AM, beo wulf wrote:

> multi-methods vocab only shows parsing words
> 
> GENERIC:
> M:
> METHOD:
> 
> Those look like they only dispatch on one arg. What am I missing?

The version of GENERIC: from multi-methods defines methods with multiple 
dispatch. The METHOD: syntax takes an array of dispatch types, as follows:

USING: multi-methods kernel ;
! override the default GENERIC: syntax with multi-methods GENERIC:
FROM: multi-methods => GENERIC: ;

SINGLETON: paper
SINGLETON: scissors
SINGLETON: rock

GENERIC: beats? ( obj1 obj2 -- ? )

METHOD: beats? { paper scissors } 2drop t ;
METHOD: beats? { scissors rock } 2drop t ;
METHOD: beats? { rock paper } 2drop t ;
METHOD: beats? { object object } 2drop f ;

Unfortunately, it looks like the vocabulary isn't fully documented; however, 
you can see additional examples under extra/multi-methods/tests/ .

-Joe
------------------------------------------------------------------------------
Learn how Oracle Real Application Clusters (RAC) One Node allows customers
to consolidate database storage, standardize their database environment, and, 
should the need arise, upgrade to a full multi-node Oracle RAC database 
without downtime or disruption
http://p.sf.net/sfu/oracle-sfdevnl
_______________________________________________
Factor-talk mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/factor-talk

Reply via email to