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

best means of passing refinements from main to helper function?

 [1/7] from: princepawn:mailandnews at: 15-Sep-2000 16:30


I want to know the best way to propagate refinement selections (or their lack) to a function which actually does the processing for them. deduction: func [/use-month month-to-use /use-day day-to-use] [ rejoin [ "file-" either use-month [ month-to-use ] [ now/month ] either use-day [ day-to-use ] [ now/day ] ] ] main [/use-month month-to-use /use-day day-to-use ] [ ; --- dilemma: ; --- I can call deduction with ; --- a - no refinements ; --- b - either or 1 refinement ; --- c - both refinements ; and I dont want a bunch of hairy eithers and ifs to create ; all the various refinements to send to deduction ] terrence-brannon: [[princepawn--yahoo--com] perl-refugee myth-gamer] free-email: http://www.MailAndNews.com free-usenet: http://www.mailAndNews.com ; all the above is real REBOL code, believe it or not.

 [2/7] from: jelinem1:nationwide at: 15-Sep-2000 16:14


This seems to be an occasionally reoccurring topic. In short I don't think anyone has come up with a simple elegant way of doing this. A few of us have come up with solutions which involve building the helper-function call/refinements string. You might find, however, that you would rather use a bunch of 'if statements. - Michael Jelinek [princepawn--MailAndNews--com]@MailAndNews.com> on 09/15/2000 03:30:03 PM From: [princepawn--MailAndNews--com]@MailAndNews.com on 09/15/2000 03:30 PM Please respond to [list--rebol--com] Sent by: Terrence Brannon <[princepawn--MailAndNews--com]> To: [list--rebol--com] cc: Subject: [REBOL] best means of passing refinements from main to helper function? I want to know the best way to propagate refinement selections (or their lack) to a function which actually does the processing for them. deduction: func [/use-month month-to-use /use-day day-to-use] [ rejoin [ "file-" either use-month [ month-to-use ] [ now/month ] either use-day [ day-to-use ] [ now/day ] ] ] main [/use-month month-to-use /use-day day-to-use ] [ ; --- dilemma: ; --- I can call deduction with ; --- a - no refinements ; --- b - either or 1 refinement ; --- c - both refinements ; and I dont want a bunch of hairy eithers and ifs to create ; all the various refinements to send to deduction ] terrence-brannon: [[princepawn--yahoo--com] perl-refugee myth-gamer] free-email: http://www.MailAndNews.com free-usenet: http://www.mailAndNews.com ; all the above is real REBOL code, believe it or not.

 [3/7] from: jeff:rebol at: 15-Sep-2000 14:04


Howdy, Michael: The following approach is exactly elegant, but it gets the job done and it's fairly short. I think it's kind of cute. -jeff REBOL [] deduction: func [ /use-month month-to-use /use-day day-to-use ][ rejoin [ "file-" either use-month [ month-to-use ] [ now/month ] either use-day [ day-to-use ] [ now/day ] ] ] main: func [ /use-month month-to-use /use-day day-to-use ] [ go?: func ['what /it][either it: get what [either true = it [what][it]][]] do reduce compose/deep [to-path [deduction (go? use-month) (go? use-day)] (go? month-to-use) (go? day-to-use)] ]

 [4/7] from: jeff:rebol at: 15-Sep-2000 15:09


> Howdy, Michael: > > The following approach is exactly elegant, but it gets
I meant to say "ISN't exactly elegant"... sorry. That wasn't very elegant either! :)
> the job done and it's fairly short. I think it's kind of > cute.
-jeff

 [5/7] from: alienguy3::juno::com at: 16-Sep-2000 9:54


I don't have the E-mail. Can you resend that original one?

 [6/7] from: jelinem1:nationwide at: 18-Sep-2000 8:35


But then this (the example below) explicitly lists the refinements in the function body. I think the "ultimate" solution would process an arbitray list, as with a loop. It is fairly short though :) and IS a step up from 'if statements, esp for more than 2 refinements. - Michael Jelinek [jeff--rebol--net] on 09/15/2000 04:04:34 PM From: [jeff--rebol--net] on 09/15/2000 04:04 PM Please respond to [list--rebol--com] To: [list--rebol--com] cc: Subject: [REBOL] best means of passing refinements from main to helper function? Re:(2) Howdy, Michael: The following approach is exactly elegant, but it gets the job done and it's fairly short. I think it's kind of cute. -jeff REBOL [] deduction: func [ /use-month month-to-use /use-day day-to-use ][ rejoin [ "file-" either use-month [ month-to-use ] [ now/month ] either use-day [ day-to-use ] [ now/day ] ] ] main: func [ /use-month month-to-use /use-day day-to-use ] [ go?: func ['what /it][either it: get what [either true = it [what][it]] []] do reduce compose/deep [to-path [deduction (go? use-month) (go? use-day)] (go? month-to-use) (go? day-to-use)] ]

 [7/7] from: jeff:rebol at: 18-Sep-2000 8:21


> But then this (the example below) explicitly lists the > refinements in the function body. I think the "ultimate" > solution would process an arbitray list, as with a loop. It > is fairly short though :) and IS a step up from 'if > statements, esp for more than 2 refinements. > > - Michael Jelinek
Yes, like I meant to say: it's not exactly elegant. (: Refinement transferal is at the frontiers of REBOL research. ;) -jeff