Starting work on advice vocab

db4
James Cash 2008-11-05 09:19:59 -05:00
parent f5db48e3b7
commit f8da0cd23f
5 changed files with 38 additions and 0 deletions

View File

View File

@ -0,0 +1,5 @@
! Copyright (C) 2008 James Cash
! See http://factorcode.org/license.txt for BSD license.
USING: kernel sequences tools.tests advice ;
IN: advice.tests

View File

@ -0,0 +1,29 @@
! Copyright (C) 2008 James Cash
! See http://factorcode.org/license.txt for BSD license.
USING: kernel sequences symbols fry words assocs tools.annotations ;
IN: advice
SYMBOLS: before after around ;
: get-advice ( word type -- seq )
word-prop values ;
: call-before ( word -- )
before get-advice [ call ] each ;
: call-after ( word -- )
after get-advice [ call ] each ;
: advise-before ( quot name word -- )
before word-prop set-at ;
: advise-after ( quot name word -- )
after word-prop set-at ;
: remove-advice ( name word loc -- )
word-prop delete-at ;
: make-advised ( word -- )
[ dup [ over '[ _ call-before @ _ call-after ] ] annotate ]
[ { before after around } [ H{ } clone swap set-word-prop ] with each ] bi ;

1
extra/advice/authors.txt Normal file
View File

@ -0,0 +1 @@
James Cash

3
extra/advice/tags.txt Normal file
View File

@ -0,0 +1,3 @@
advice
aspect
annotations