But (unless I don't get it, here) this uses exactly what I am trying to
avoid using: an 'if statement for each possible refinement. I agree it's
easier and more straight forward, but it also creates more work to maintain
(such as when refinements are added to a function). Since I use this
"pass-through of refinements" idea as a common practice in my program, the
added maintenance adds up.

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, May 24, 2000 8:38 PM
To: [EMAIL PROTECTED]
Subject: [REBOL] refinements Re:


> I want to pass all of the given refinements to another function.

There's a better way of doing this. Just 'append (you have to replace
'append with a better 'append, though) the refinements of the function to
the function as a path.

Like this:


; A replacement 'append function that doesn't evaluate 'series and uses a
refined path for 'insert.
append: function [
 {Appends a value to the tail of a series and returns the series head.}
 series [series! port!]
 value
 /only {Appends a block value into a block series as a block}
 ][
 Refined_Insert
 ][
 Refined_Insert: to path! 'insert
 if only [head insert tail :Refined_Insert 'only]
 head Refined_Insert tail :series :value
 ]

And this function shows how to use it:

SNA_switch: function [
 "Selects a choice and evaluates what follows it."
 value "Value to search for."
 cases [block!] "Block of cases to search."
 /case "Value is case-sensitive."
 /only "Treats a series value as a single value."
 /any "Enables the * and ? wildcards."
 /default Default_Case "Default case if no others are found."
 ][
 Refined_Select
 ][
 Refined_Select: to path! 'select
 if case [head insert tail :Refined_Select 'case]
 if only [head insert tail :Refined_Select 'only]
 if any [head insert tail :Refined_Select 'any]
 either found? value: Refined_Select cases value [
  do value
  ][
  either default [
   do Default_Case
   ][
   none
   ]
  ]
 ]

I hope that helps!

Andrew Martin
Refined REBOLite...
ICQ: 26227169
http://members.xoom.com/AndrewMartin/
-><-

Reply via email to