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

Propagating Refinements

 [1/10] from: lmecir:mbox:vol:cz at: 10-Sep-2001 21:04


Hi, you should look at my do-path function (in highfun.r too) Regards Ladislav

 [2/10] from: greggirwin:starband at: 10-Sep-2001 17:05


<< you should look at my do-path function (in highfun.r too) >> Thanks! Sometimes I go right by the thing I'm looking for.<g> --Gregg

 [3/10] from: greggirwin:starband at: 10-Sep-2001 11:58


Is it possible to, in a simple way, propagate refinements to other functions? For example, I want my stack/add routine to support an /only refinement, which it then passes on to insert (example code below). Can you do it without an either clause, or getting more involved as Ladislav's refined function does? Thanks! --Gregg stack: make object! [ _data: make block! 25 ; Use list! instead of block!? clear: does [_data: make block! 25] count: does [return length? _data] empty?: does [return count = 0] item: does [if not empty? [return last _data]] remove: does [if not empty? [system/words/remove back tail _data]] add: func [value /only] [ either only [ insert/only tail _data :value ][ insert tail _data :value ] ] contains?: func [value /only] [ either only [ return found? find/only _data value ][ return found? find _data value ] ] ]

 [4/10] from: sunandadh:aol at: 21-Dec-2001 9:21


A simple question, I hope. Is there any way of passing refinements from one function to another? In the example below, I want to recursively call Flag-Item with the same refinements it was called with. But without that double IF (or an equivalent Either), I don't know how; and this method gets a bit wearisome when there are two or more I want to propagate. flag-item: func [tree-Node [Object!] /Deleted /ReInstated] [ ;; Flags current node and all its descendants ;;as deleted or reInstated Tree-Node/Status: either Reinstated [True] [False] foreach Inner-tree Tree-Node/Inners [ if Deleted [Flag-item/Deleted Inner-Tree] if ReInstated [Flag-item/ReInstated Inner-Tree] ] ] Thanks, Sunanda.

 [5/10] from: lmecir:mbox:vol:cz at: 21-Dec-2001 18:46


Hi Sunanda, have a look at the Apply function that can be found in http://www.sweb.cz/LMecir/highfun.r . ----- Original Message ----- From: <[SunandaDH--aol--com]> To: <[rebol-list--rebol--com]> Sent: Friday, December 21, 2001 3:21 PM Subject: [REBOL] Propagating refinements A simple question, I hope. Is there any way of passing refinements from one function to another? In the example below, I want to recursively call Flag-Item with the same refinements it was called with. But without that double IF (or an equivalent Either), I don't know how; and this method gets a bit wearisome when there are two or more I want to propagate. flag-item: func [tree-Node [Object!] /Deleted /ReInstated] [ ;; Flags current node and all its descendants ;;as deleted or reInstated Tree-Node/Status: either Reinstated [True] [False] foreach Inner-tree Tree-Node/Inners [ if Deleted [Flag-item/Deleted Inner-Tree] if ReInstated [Flag-item/ReInstated Inner-Tree] ] ] Thanks, Sunanda.

 [6/10] from: rotenca:telvia:it at: 21-Dec-2001 19:06


Hi Sunanda,
> In the example below, I want to recursively call Flag-Item with the same > refinements it was called with. But without that double IF (or an equivalent > Either), I don't know how; and this method gets a bit wearisome when there > are two or more I want to propagate.
I have uploaded my refine.r on the rebol library. You can find it also in http://web.tiscali.it/anarkick/refine.r My approach is different from Ladislav's one. --- Ciao Romano

 [7/10] from: greggirwin:mindspring at: 21-Dec-2001 11:49


Hi Sunanda, << A simple question, I hope. Is there any way of passing refinements from one function to another? >> The simple answer is to get Ladislav's highfun.r stuff. He has a routine called 'refined that provides support for that. The not-so-simple answer you will see when you look at his code. :) --Gregg

 [8/10] from: sunandadh:aol at: 21-Dec-2001 19:59


Thanks for the responses. I think I'll stick to passing parameters as strings if they have to go anywhere other than the function invoked, eg: flag-item: func [tree-Node [Object!] Action [String!]] [ ;; Flags current node and all its descendants ;;as deleted or reInstated Tree-Node/Status: either Action = "Reinstated" [True] [False] foreach Inner-tree Tree-Node/Inners [ Flag-item Inner-Tree Action ] ] Sunanda.

 [9/10] from: greggirwin:mindspring at: 22-Dec-2001 12:52


Hi Sunanda, << I think I'll stick to passing parameters as strings if they have to go anywhere other than the function invoked >> Hmmm. What about a block of optional refinements? Then you can just pass that entire block, rather than individual parameters. Sadly, the syntax isn't nearly as nice as using regular refinements, but it could be a very flexible approach for special cases. fn-test: func [ opt [series!] {options are: /ref1, /ref2 arg} /local arg ][ if find opt /ref1 [print "ref1"] if arg: select opt /ref2 [print ["ref2" arg]] ] fn-test [] fn-test [/ref1] fn-test [/ref2 1] fn-test [/ref1 /ref2 1] Just a thought. --Gregg

 [10/10] from: sunandadh:aol at: 22-Dec-2001 17:28


Hi Gregg,
> << I think I'll stick to passing parameters as strings if they have to go > anywhere other than the function invoked >> > > Hmmm. What about a block of optional refinements? Then you can just pass > that entire block, rather than individual parameters. Sadly, the syntax > isn't nearly as nice as using regular refinements, but it could be a very > flexible approach for special cases. >
That's a nice idea, and you could do the same sort of thing to pass, in effect, a variable number of parameters to a function, e.g. the fictitious UpLoadFiles function UpLoadFiles [/replace /quiet /ascii] [%file1 %file2 %file3 ...] Sunanda.