Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[Refinements] Passing Refinements

 [1/5] from: pwawood::mango::net::my at: 5-Feb-2005 17:25


In September 2000, Jeff of Rebol Technologies said :
>Yes, like I meant to say: it's not exactly elegant. (: Refinement
transferal (sic) is at the frontiers of REBOL
>research. ;) -jeff
Did anything ever come of this? I'm trying to find "elegant" ways of dealing with mutually exclusive refinements and passing refinements through a heirarchy of functions. Regards Peter

 [2/5] from: gabriele::colellachiara::com at: 5-Feb-2005 12:15


Hi Peter, On Saturday, February 5, 2005, 10:25:43 AM, you wrote: P> Did anything ever come of this? I'm trying to find "elegant" ways of dealing P> with mutually exclusive refinements and passing refinements through a P> heirarchy of functions. For a general solution for passing refinements and arguments, you can use Ladislav's PASS-ARGS etc. If you have a more specific need, there are less general but faster/more elegant ways to "pass" arguments and refinements (in the end, you avoid passing them at all, and just share the context). About mutual exclusion, there's nothing built-in, so you'll need to use the usual logic. Regards, Gabriele. -- Gabriele Santilli <[g--santilli--tiscalinet--it]> -- REBOL Programmer Amiga Group Italia sez. L'Aquila --- SOON: http://www.rebol.it/

 [3/5] from: pwawood:mango:my at: 6-Feb-2005 19:02


Hi Gabriele Thanks for the advice. I'll start looking into sharing contexts. What I'm doing is very simple, it's basically A: func [/refa /refb] [ either refa [b/refa] [either refb [b/refb] [b] ] ] Regards Peter

 [4/5] from: gabriele::colellachiara::com at: 6-Feb-2005 13:38


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 <[g--santilli--tiscalinet--it]> -- REBOL Programmer Amiga Group Italia sez. L'Aquila --- SOON: http://www.rebol.it/

 [5/5] from: pwawood::mango::net::my at: 7-Feb-2005 10:06


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: