[REBOL] Refinements Re:
Hi Colin, Hopefully this will give you an idea. we can't use the path notation of data-struct/"string" but we can use it this way path: "string" data-struct/:path ;---Here's a modified version of your example. data-struct: [ this: 1 words: [ "some-word" [ title "some-title" ] ] "one" [1] "two" [2] "three" [3] "four" [4] ] foreach item count [probe data-struct/:item] ; result is [1] [2] [3] [4] ;- Cheers, Allen K Thanks in anticipation colinb Colin Brizell IT System Development Officer University College Worcester Tel: 01905 855389 Fax: 01905 855330 http://www.worc.ac.uk
[REBOL] refinements Re:(8)
-Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Tuesday, May 30, 2000 8:51 PM To: [EMAIL PROTECTED] Subject: [REBOL] refinements Re:(7) [EMAIL PROTECTED] wrote: What you are missing is that I want the function element of door-man (speak) to call a global function defined outside of the object to perform the functionality. I think your design needs better encapsulation. I prefer to have objects which can act under their own power, without having to rely on unrelated functions to hold their hand. :) I know it sounds flaky, and might even defeat the purpose for defining the function element in the first place (ie why don't I just call the global function directly?) if I didn't think I knew better :). I suppose the real reason why I'm comfortable with it is that I'm not an OO programmer, I just borrow OO concepts to improve my programming. Another is that the "global" functions I am calling aren't used as global - they are only global because REBOL doesn't suport a module context. I really just want to separate the definition of the method (function body) from the object, but I still want the method to be called as part of the object. Some of these objects can be saved to a file and reloaded, and I want the function "bound" to the latest definition in the program, not what the definition was at the time that the object was saved. Also, although I can't claim to "know" the internals of REBOL, I don't want multiple copies (or worse, definitions) of the function floating around - it's inefficient. If you're trying to communicate between actor objects, making a communications object or make a block/dialect with the message in it. So that you reduce interdependence in the design. My objects are dependent on certain function definitions in the program to make them work - this is by design. I guess, if you are looking at these from a stricter OO point of view, these are "broken" or "crippled" objects. The method functions in the program are logically private only to the associated object. The concept of a "communications object" is new to me, though. I'll have to meditate on that. I wonder if I can create a single "melee" object... I hope that helps. You have valid points, well taken. I may be trying to push REBOL into doing things that it is not designed (well) for. - Michael Jelinek
[REBOL] refinements Re:(6)
What you are missing is that I want the function element of door-man (speak) to call a global function defined outside of the object to perform the functionality. Otherwise, how the object gets defined (either through make object! or a template object) doesn't really matter. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Friday, May 26, 2000 5:14 PM To: [EMAIL PROTECTED] Subject: [REBOL] refinements Re:(5) Michael Jelinek wrote: door-man: make object! [ vocab1: "hello" vocab2: "world" speak: func [][say-greeting self] ] say-greeting: func [idiot][ print [idiot/vocab1 idiot/vocab2] ] door-man/speak May be I'm missing something crucial, but wouldn't this be simpler: Person: [ vocab1: string! vocab2: string! speak: func [] [ print [vocab1 vocab2] ] ] Extend: func [Base [block!] Extension [block!]] [ append copy/deep Base Extension ] door-man: make object! Extend Person [ vocab1: "hello" vocab2: "world" ] door-man/speak I'm sure that I must be missing something important. Can you let me know what it is, please? Andrew Martin Black boxer... ICQ: 26227169 http://members.xoom.com/AndrewMartin/ --
[REBOL] refinements Re:(9)
Hi Michael, just one warning. The code is not very universal, it may not work correctly, if the word 'path-list or 'r-word are between the refinements. (BTW, have you looked at my Refine function? - it has got its limitations too - it is not suitable for the functions with unevaluated arguments) Regards Ladislav That works! And yes, was close to what I was doing (but better). -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Saturday, May 27, 2000 2:25 AM To: [EMAIL PROTECTED] Subject: [REBOL] refinements Re:(7) Hi, is this close to what you wanted to have? f1: function [/va /vb /vc][path-list r-word][ path-list: to path! 'f2 foreach r first :f1 [ if all [ refinement? r r /local get r-word: bind to word! r 'r-word ] [ insert tail :path-list r-word ] ] print ["Calling path:" mold :path-list] ] Regards Ladislav
[REBOL] refinements Re:(9)
Hi, just to diversify, here's my try ... REBOL [ Title: "Test for refinement propagation" ] a: func [ /c "do c" /d "do d" /e "do e" /local x y ] [ either any [ c d e ] [ if c [print "C"] if d [print "D"] if e [print "E"] ] [ print "No refinement" ] exit ] ; get refinements directly from the function to be called b: function head clear find copy third :a /local [call ref] [ call: copy [a] foreach ref first :a [ if refinement? ref [ if not none? get bind to-word ref 'call [ append call to-word ref ] ] ] do mold to-path call ] b b/a b/c/d halt ; - end of script regards, Ingo -- _ ._ ingo@)|_ /| _| _ We ARE all ONE www._|_o _ _ ._ _ www./_|_) |o(_|(/_ We ARE all FREE ingo@| |(_|o(_)| (_| http://www.2b1.de/Rebol/ ._| ._|
[REBOL] refinements Re:(7)
[EMAIL PROTECTED] wrote: What you are missing is that I want the function element of door-man (speak) to call a global function defined outside of the object to perform the functionality. I think your design needs better encapsulation. I prefer to have objects which can act under their own power, without having to rely on unrelated functions to hold their hand. If you're trying to communicate between actor objects, making a communications object or make a block/dialect with the message in it. So that you reduce interdependence in the design. I hope that helps. Andrew Martin ICQ: 26227169 http://members.xoom.com/AndrewMartin/ --
[REBOL] refinements Re:(7)
Hi, is this close to what you wanted to have? f1: function [/va /vb /vc][path-list r-word][ path-list: to path! 'f2 foreach r first :f1 [ if all [ refinement? r r /local get r-word: bind to word! r 'r-word ] [ insert tail :path-list r-word ] ] print ["Calling path:" mold :path-list] ] Regards Ladislav f1: function [/va /vb /vc][param-list param-values r path-list][ param-list: make block! [] param-values: make block! [] foreach r first :f1 [ if (refinement? r) and (r /local) [ append param-list r append param-values get bind to-word r 'param-list ]] path-list: join [f2] param-list print ["Calling path:" mold to-path path-list] do to-path path-list ] f2: function [param-list][va vb vc][ foreach r param-list [ print r ] ] f1/vb Calling path: f2//va//vb//vc Doesn't work (yet). - Michael Jelinek -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Friday, May 26, 2000 10:10 AM To: [EMAIL PROTECTED] Subject: [REBOL] refinements Re:(5) Funny that you mention it. It slipped from our lists, but we do need to evaluate dynamically built refinement blocks. E.g: do to-path [insert part] a b Should be the same as: insert/part a b Comments? -Carl At 5/26/00 08:55 AM -0700, you wrote: Oh yes, I've considered restructuring things, but the current arcitecture is the one that best suits all of my needs (the best one that I have been able to think of, anyway). Specifically, when I define a function element in an object, that function does nothing more than to call another function (not defined as part of the object) to do the work. For example: door-man: make object! [ vocab1: "hello" vocab2: "world" speak: func [][say-greeting self] ] say-greeting: func [idiot][ print [idiot/vocab1 idiot/vocab2] ] door-man/speak This simple example is neat and clean. The messy part is when I also have to pass-through refinements. Then I not only have to keep both functions in sync with the refinement list, but I also have to keep the 'if statements in sync. I've been doing that with the assumption that I only specify a single refinement at a time. To save me just that much more work, it'd be nice to have some automatic way of passing the refinements. I have considered passing the refinements as a block, and even the idea of defining them as an object (within the pass-through function) is appealing. This involves looping to get the refinement! values from the first block of the function. But the only way I know how to get the value of a refinement! type is to cast it as a word!, then use 'get, then bind it to the current context (ick). It seems like there should be a way to evaluate a refinement! type directly. That would make me happy. - Michael Jelinek -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Friday, May 26, 2000 2:30 AM To: [EMAIL PROTECTED] Subject: [REBOL] refinements Re:(3) [EMAIL PROTECTED] wrote: 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. It's only one 'if per refinement that's to be passed through. It avoids multiple combinations of 'ifs. For each refinement added, it's only one extra 'if to write. I believe that this approach is only a small price to pay. If you're commonly passing refinements through to subfunctions, consider restructuring your software. It may be better to use a different approach, perhaps using objects? YMMV. :-) Andrew Martin ICQ: 26227169 http://members.xoom.com/AndrewMartin/ --
[REBOL] refinements Re:(8)
Hi, this thread inspired me to write: to-func: func [ {Create a function doing the same thing as a function with given refinements does} [catch] f [any-function!] refinements [block!] /local spec body f-spec mode append-mode item n holder getargs simple-spec ] [ append-mode: [ if not refinement? :item [ either block? :item [ append/only spec load mold :item ] [ append/only spec :item ] ] ] spec: copy [] f-spec: third :f mode: append-mode while [not tail? f-spec] [ item: first f-spec f-spec: next f-spec do mode if refinement? :item [ if :item = /local [break] item: to word! :item either find refinements :item [ mode: append-mode ] [ mode: [] ] ] ] simple-spec: first func spec [] holder: make object! compose/deep [f: first [(:f)]] body: bind compose [ (:holder) (to path! append copy [f] refinements) ( getargs: copy [] foreach arg simple-spec [ append getargs compose [get/any (arg)] ] getargs ) ] in holder 'f func spec body ] { Example: insert-only: to-func :insert [only] } Regards Ladislav
[REBOL] refinements Re:(9)
Oops, cut/pasted the not-working version (see the difference between the line: append getargs compose [get/any (arg)] append getargs compose [get/any (to lit-word! arg)] ). My apologies to all. Regards Ladislav refined: func [ {Create a function doing the same thing as a function with given refinements does} [catch] f [any-function!] refinements [block!] /local spec body f-spec mode append-mode item holder getargs simple-spec ] [ append-mode: [ if not refinement? :item [ either block? :item [ append/only spec load mold :item ] [ append/only spec :item ] ] ] spec: copy [] f-spec: third :f mode: append-mode while [not tail? f-spec] [ item: first f-spec f-spec: next f-spec do mode if refinement? :item [ if :item = /local [break] item: to word! :item either find refinements :item [ mode: append-mode ] [ mode: [] ] ] ] simple-spec: first func spec [] holder: make object! compose/deep [f: first [(:f)]] body: bind compose [ (:holder) (to path! append copy [f] refinements) ( getargs: copy [] foreach arg simple-spec [ append getargs compose [get/any (to lit-word! arg)] ] getargs ) ] in holder 'f func spec body ] { Example: insert-only: refined :insert [only] }
[REBOL] refinements Re:(3)
[EMAIL PROTECTED] wrote: 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. It's only one 'if per refinement that's to be passed through. It avoids multiple combinations of 'ifs. For each refinement added, it's only one extra 'if to write. I believe that this approach is only a small price to pay. If you're commonly passing refinements through to subfunctions, consider restructuring your software. It may be better to use a different approach, perhaps using objects? YMMV. :-) Andrew Martin ICQ: 26227169 http://members.xoom.com/AndrewMartin/ --
[REBOL] refinements Re:(4)
Oh yes, I've considered restructuring things, but the current arcitecture is the one that best suits all of my needs (the best one that I have been able to think of, anyway). Specifically, when I define a function element in an object, that function does nothing more than to call another function (not defined as part of the object) to do the work. For example: door-man: make object! [ vocab1: "hello" vocab2: "world" speak: func [][say-greeting self] ] say-greeting: func [idiot][ print [idiot/vocab1 idiot/vocab2] ] door-man/speak This simple example is neat and clean. The messy part is when I also have to pass-through refinements. Then I not only have to keep both functions in sync with the refinement list, but I also have to keep the 'if statements in sync. I've been doing that with the assumption that I only specify a single refinement at a time. To save me just that much more work, it'd be nice to have some automatic way of passing the refinements. I have considered passing the refinements as a block, and even the idea of defining them as an object (within the pass-through function) is appealing. This involves looping to get the refinement! values from the first block of the function. But the only way I know how to get the value of a refinement! type is to cast it as a word!, then use 'get, then bind it to the current context (ick). It seems like there should be a way to evaluate a refinement! type directly. That would make me happy. - Michael Jelinek -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Friday, May 26, 2000 2:30 AM To: [EMAIL PROTECTED] Subject: [REBOL] refinements Re:(3) [EMAIL PROTECTED] wrote: 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. It's only one 'if per refinement that's to be passed through. It avoids multiple combinations of 'ifs. For each refinement added, it's only one extra 'if to write. I believe that this approach is only a small price to pay. If you're commonly passing refinements through to subfunctions, consider restructuring your software. It may be better to use a different approach, perhaps using objects? YMMV. :-) Andrew Martin ICQ: 26227169 http://members.xoom.com/AndrewMartin/ --
[REBOL] refinements Re:(5)
Funny that you mention it. It slipped from our lists, but we do need to evaluate dynamically built refinement blocks. E.g: do to-path [insert part] a b Should be the same as: insert/part a b Comments? -Carl At 5/26/00 08:55 AM -0700, you wrote: Oh yes, I've considered restructuring things, but the current arcitecture is the one that best suits all of my needs (the best one that I have been able to think of, anyway). Specifically, when I define a function element in an object, that function does nothing more than to call another function (not defined as part of the object) to do the work. For example: door-man: make object! [ vocab1: "hello" vocab2: "world" speak: func [][say-greeting self] ] say-greeting: func [idiot][ print [idiot/vocab1 idiot/vocab2] ] door-man/speak This simple example is neat and clean. The messy part is when I also have to pass-through refinements. Then I not only have to keep both functions in sync with the refinement list, but I also have to keep the 'if statements in sync. I've been doing that with the assumption that I only specify a single refinement at a time. To save me just that much more work, it'd be nice to have some automatic way of passing the refinements. I have considered passing the refinements as a block, and even the idea of defining them as an object (within the pass-through function) is appealing. This involves looping to get the refinement! values from the first block of the function. But the only way I know how to get the value of a refinement! type is to cast it as a word!, then use 'get, then bind it to the current context (ick). It seems like there should be a way to evaluate a refinement! type directly. That would make me happy. - Michael Jelinek -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Friday, May 26, 2000 2:30 AM To: [EMAIL PROTECTED] Subject: [REBOL] refinements Re:(3) [EMAIL PROTECTED] wrote: 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. It's only one 'if per refinement that's to be passed through. It avoids multiple combinations of 'ifs. For each refinement added, it's only one extra 'if to write. I believe that this approach is only a small price to pay. If you're commonly passing refinements through to subfunctions, consider restructuring your software. It may be better to use a different approach, perhaps using objects? YMMV. :-) Andrew Martin ICQ: 26227169 http://members.xoom.com/AndrewMartin/ --
[REBOL] refinements Re:(6)
Carl, Yes, I would expect that (your example) to work. If I had thought of it. That does directly relate to my problem, where I would build a block of refinements. It would be nice to throw a to-path on the block directly. Currently I've had to piece together a string out of it: "f2/va/vb/vc". f1: function [/va /vb /vc][param-list param-values r path-list][ param-list: make block! [] param-values: make block! [] foreach r first :f1 [ if (refinement? r) and (r /local) [ append param-list r append param-values get bind to-word r 'param-list ]] path-list: join [f2] param-list print ["Calling path:" mold to-path path-list] do to-path path-list ] f2: function [param-list][va vb vc][ foreach r param-list [ print r ] ] f1/vb Calling path: f2//va//vb//vc Doesn't work (yet). - Michael Jelinek -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Friday, May 26, 2000 10:10 AM To: [EMAIL PROTECTED] Subject: [REBOL] refinements Re:(5) Funny that you mention it. It slipped from our lists, but we do need to evaluate dynamically built refinement blocks. E.g: do to-path [insert part] a b Should be the same as: insert/part a b Comments? -Carl At 5/26/00 08:55 AM -0700, you wrote: Oh yes, I've considered restructuring things, but the current arcitecture is the one that best suits all of my needs (the best one that I have been able to think of, anyway). Specifically, when I define a function element in an object, that function does nothing more than to call another function (not defined as part of the object) to do the work. For example: door-man: make object! [ vocab1: "hello" vocab2: "world" speak: func [][say-greeting self] ] say-greeting: func [idiot][ print [idiot/vocab1 idiot/vocab2] ] door-man/speak This simple example is neat and clean. The messy part is when I also have to pass-through refinements. Then I not only have to keep both functions in sync with the refinement list, but I also have to keep the 'if statements in sync. I've been doing that with the assumption that I only specify a single refinement at a time. To save me just that much more work, it'd be nice to have some automatic way of passing the refinements. I have considered passing the refinements as a block, and even the idea of defining them as an object (within the pass-through function) is appealing. This involves looping to get the refinement! values from the first block of the function. But the only way I know how to get the value of a refinement! type is to cast it as a word!, then use 'get, then bind it to the current context (ick). It seems like there should be a way to evaluate a refinement! type directly. That would make me happy. - Michael Jelinek -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Friday, May 26, 2000 2:30 AM To: [EMAIL PROTECTED] Subject: [REBOL] refinements Re:(3) [EMAIL PROTECTED] wrote: 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. It's only one 'if per refinement that's to be passed through. It avoids multiple combinations of 'ifs. For each refinement added, it's only one extra 'if to write. I believe that this approach is only a small price to pay. If you're commonly passing refinements through to subfunctions, consider restructuring your software. It may be better to use a different approach, perhaps using objects? YMMV. :-) Andrew Martin ICQ: 26227169 http://members.xoom.com/AndrewMartin/ --
[REBOL] refinements Re:(5)
Michael Jelinek wrote: door-man: make object! [ vocab1: "hello" vocab2: "world" speak: func [][say-greeting self] ] say-greeting: func [idiot][ print [idiot/vocab1 idiot/vocab2] ] door-man/speak May be I'm missing something crucial, but wouldn't this be simpler: Person: [ vocab1: string! vocab2: string! speak: func [] [ print [vocab1 vocab2] ] ] Extend: func [Base [block!] Extension [block!]] [ append copy/deep Base Extension ] door-man: make object! Extend Person [ vocab1: "hello" vocab2: "world" ] door-man/speak I'm sure that I must be missing something important. Can you let me know what it is, please? Andrew Martin Black boxer... ICQ: 26227169 http://members.xoom.com/AndrewMartin/ --
[REBOL] refinements Re:(2)
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/ --
[REBOL] refinements Re:
Hi Michael, here's another idea: 1. Use refine-func instead of func to create a function. 2. Use call-with-refine to call a function with refinements. Example: Given the function f: f: func [/a /b /c][if a [print 'a] if b [print 'b] if c [print 'c]] You can create a calling function g: g: refine-func [/a /b /c] [ call-with-refine f refinements ] Such that: g == false g/a a == false g/b b == false g/c c == false Here are the two functions refine-func and call-with-refine: refine-func: func [spec body /local refinements] [ refinements: make block! length? spec foreach word spec [ if all [ refinement? word word /local ] [ append refinements to word! word ] ] insert body compose/deep [ refinements: make block! 0 foreach word [(refinements)] [ if get :word [ append refinements word ] ] ] either found? find spec /local [ append spec 'refinements ][ append spec [/local refinements] ] return func spec body ] call-with-refine: func [:f ref-block [block!] /local g] [ g: make path! compose [f (ref-block)] g ] Oh, by the way, the function defined as g: refine-func [/a /b /c] [ call-with-refine f refinements ] ends up looking like this: source g g: func [/a /b /c /local refinements][ refinements: make block! 0 foreach word [a b c] [ if get :word [append refinements word]] call-with-refine f refinements] At 12:50 PM 5/24/00 -0700, you wrote: A while back a message was posted to the list (can't find it now) about wanting to loop on the refinements specified to a function, without an 'if for each one. I've finally come up with a reason to do something similar: I want to pass all of the given refinements to another function. That is: - I call func A, giving some refinements - func A calls func B with all of the refinements given to func A I have been doing the 'if thing on each possible refinent of A and performing a different (hard-coded) call of B with each different refinement, but this would get messy if I were to specify more than one refinement at a time. I have found an "automatic" way of building the funcname/refinement string, but I haven't found any "slick" way of doing it. BTW the code below could be improved by recognizing only refinement! from the first func block. However, I haven't decided whether I even want to use it. f1: function [/a /b /c][local1 local2 local3][ ; Calls function F2 with the refinements given to this function ; MUST define [local1 local2 local3] (exactly) as locals to this function local3: :f1 do bind refine 'local1 do join "f2" local1 ] f2: func [/a /b /c][if a [print "a"] if b [print "b"] if c [print "c"]] ; Then, somewhere in the code specify the block: refine: [ local1: make string! length? first :local3 ; Assume that no other parameters were specified repeat local2 length? first :local3 [ if true = get bind to-word pick first :local3 local2 'local1 [append local1 join "/" pick first :local3 local2] ] ] ; Example use: f1/b b == none f1/b/c b c - Michael Jelinek ;- Elan [: - )]
[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/ --