1 ! Copyright (C) 2008, 2009 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: parser kernel words generic namespaces effects.parser ;
6 ERROR: not-in-a-method-error ;
8 : CREATE-GENERIC ( -- word ) CREATE dup reset-word ;
10 : (GENERIC:) ( quot -- )
11 [ CREATE-GENERIC ] dip call complete-effect define-generic ; inline
13 : create-method-in ( class generic -- method )
14 create-method dup set-word dup save-location ;
16 : define-inline-method ( class generic quot -- )
17 [ create-method-in ] dip [ define ] [ drop make-inline ] 2bi ;
19 : CREATE-METHOD ( -- method )
20 scan-word bootstrap-word scan-word create-method-in ;
22 SYMBOL: current-method
24 : with-method-definition ( method quot -- )
25 over current-method set call current-method off ; inline
27 : (M:) ( -- method def )
28 CREATE-METHOD [ parse-definition ] with-method-definition ;