From d530ec6bd5c2593b84c0b1fa60efd4657e96fdc1 Mon Sep 17 00:00:00 2001 From: James Cash Date: Thu, 6 Nov 2008 00:20:15 -0500 Subject: [PATCH] More work on around-advice --- extra/advice/advice.factor | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/extra/advice/advice.factor b/extra/advice/advice.factor index 3fb6941854..a71b9590f1 100644 --- a/extra/advice/advice.factor +++ b/extra/advice/advice.factor @@ -3,7 +3,7 @@ USING: kernel sequences symbols fry words assocs tools.annotations coroutines ; IN: advice -SYMBOLS: before after around ; +SYMBOLS: before after around advised ; : advise ( quot name word loc -- ) word-prop set-at ; @@ -28,17 +28,20 @@ SYMBOLS: before after around ; after get-advice [ call ] each ; : call-around ( main word -- ) - around get-advice [ [ coresume ] each ] dip call - around get-advice reverse [ coresume ] each ; + around get-advice tuck + [ [ coresume ] each ] [ call ] [ reverse [ coresume ] each ] tri* ; : remove-advice ( name word loc -- ) word-prop delete-at ; : ad-do-it ( input -- result ) coyield ; - + +: advised? ( word -- ? ) + advised word-prop ; : make-advised ( word -- ) [ dup [ over dup '[ _ call-before _ _ call-around _ call-after ] ] annotate ] - [ { before after around } [ H{ } clone swap set-word-prop ] with each ] bi ; + [ { before after around } [ H{ } clone swap set-word-prop ] with each ] + [ t advised set-word-prop ] tri ; \ No newline at end of file