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

[REBOL] Re: [none idiom found?] The best shortcut word for "not none?"

From: lmecir::mbox::vol::cz at: 4-Sep-2006 8:47

Gregg wrote: If you use ANY and ALL, the result may be none. The mezzanine that converts a NONE result to a logic! value is FOUND?. I was going to suggest that we add an alternative, for cases like this, to improve the readability. found? all [a = b zero? a - b] That is, I've always read FOUND? as "was the value found?", as you would when using FIND. Now, whenever I think I've caught something that Carl missed, I try to think about it a bit before requesting a change, because it usually turns out that he's thought ahead of me and did the right thing; it just takes me a little time to see it sometimes. :) So, I was going to say a new word would be nice but, when I stopped to think about it a little more, I realized that all I need to do is read it in context. In the above example, it would mean "If it is found that all the following are true...", which couldn't be clearer (I tried to come up with better words, and couldn't). So, thanks Carl, and thanks to Ladislav for making me think about this. What else in REBOL have you found that makes you think, or read code, differently? -- Gregg Thank you for highlighting this issue. You made me think about it once again and find out, that all problems may not be solved yet. My original need was to obtain a LOGIC! value, so the question is, if I shouldn't have used the TO function. Advantages: a) TO LOGIC! is twice as fast as the FOUND? mezzanine and faster than the NOT NONE? idiom b) TO LOGIC! clearly shows what my intention is c) TO LOGIC! does not behave exactly like FOUND? sometimes. See TO LOGIC! FALSE and the question is, which result is appropriate for the specific usage. For the above use this question is unimportant, but it may occur elsewhere. Even when we really need to know whether something has been found, the situation is complicated. See e.g.: found? select 1 reduce [1 none] , which is related to the question, what you expect when writing: switch/default 1 reduce [1 none] [2] Discussion and your preferences are welcome. -Ladislav