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

[REBOL] Re: probe/dump-binary survey

From: greggirwin:mindspring at: 3-May-2004 15:23

Hi Anton, Andreas, et al AR> I'd like probe to remain the simple function AR> that it is. Something beautiful about it. I agree that simple is beautiful; if we can simplify all the code that uses this functionality, even at the expense of a little added complexity inside, that's a gain IMO. Of course, it's all a balancing act to find out what we think will be best. So, here's PROBE today: probe: func [ {Prints a molded, unevaluated value and returns the same value.} value ][ print mold :value :value ] And here's what it might look like with a /dump refinement: probe: func [ {Prints a molded, unevaluated value and returns the same value.} value /dump "Display data in non-molded format" /local fn ][ either not dump [print mold :value][ fn: switch/default type?/word :value [ object! [ either attempt ['face = value/type] [:dump-face] [:dump-obj] ] binary! [:dump-bin] ;function! [:dump-func] ;bitset! [:dump-bitset] ][:probe] ] fn :value :value ] The complexity jump is quite large. :( Any other candidate host functions that map to this functionality? GI> What about a refinement on PROBE that makes it produce DUMPed GI> output? AB> no problem with that ;) however i don't how the refinement would AB> produce a benefit compared to adding just another function (named AB> dump, for example :) Ahhh, this is a really good question, which came up during the development of the ROUND function for View 1.3. Should it be separate functions for each type of rounding, or a single function with refinements? In the end, we went with the latter because the function itself gives you context. * If you type HELP ROUND, you instantly see all the options in one place * It's a way to group things * It means less to learn because once they find PROBE they've already found DUMP * You don't have to add extra docs in each one saying how they differ, you just doc the refinement that tells how it changes the behavior. I'm not trying to defend the idea here, just rambling. It's not always appropriate, and it can be misused of course, but I think there's a lot of leverage to be applied with refinements. They do make it much more important that you choose your words well and wisely though. -- Gregg