Hi Gabriele

Many thanks this is just what I needed. I use this "a calling b" 
pattern a lot to write unit tests. A is the "unit test harness" and B 
is the function being tested.

Regards

Peter

On Sunday, Feb 6, 2005, at 20:38 Asia/Kuala_Lumpur, Gabriele Santilli 
wrote:

>
> Hi Peter,
>
> On Sunday, February 6, 2005, 12:02:22 PM, you wrote:
>
> P> Thanks for the advice. I'll start looking into sharing contexts. 
> What I'm
> P> doing is very simple, it's basically
>
> P> A: func [/refa /refb] [
> P>     either refa
> P>         [b/refa]
> P>         [either refb
> P>            [b/refb]
> P>         [b]
> P>         ]
> P>     ]
>
> Special case: if B is only going to be called from A, you just do:
>
>   a: func [/refa /refb] [
>       [refa]
>       b
>   ]
>
>   b: does bind [
>       print [refa refb]
>   ] first first second :a
>
>>> a
> none none
>>> a/refa
> true none
>>> a/refb
> none true
>
> This  way you are basically making B a "slave function" of A. It's
> a  case  that  happens  relatively  often, and using this solution
> makes it very efficient too.
>
> If  B was a normal function that you wanted to call otherwise too,
> you could just do something like:
>
>
>   b: func [/refa /refb] [
>       print [refa refb]
>   ]
>
>   a: func [/refa /refb] [
>       [refa]
>       b'
>   ]
>
>   b': does bind second :b first first second :a
>
>
> Regards,
>    Gabriele.
> -- 
> Gabriele Santilli <[EMAIL PROTECTED]>  --  REBOL Programmer
> Amiga Group Italia sez. L'Aquila  ---   SOON: http://www.rebol.it/
>
> -- 
> To unsubscribe from the list, just send an email to rebol-request
> at rebol.com with unsubscribe as the subject.
>
>
>

-- 
To unsubscribe from the list, just send an email to rebol-request
at rebol.com with unsubscribe as the subject.

Reply via email to