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

[REBOL] Re: COLLECTing results

From: rotenca:telvia:it at: 25-Jul-2003 12:07

Hi Brett,
> I don't understand the issue with the paren! init value. Could you give an > example how this version of my function will not work?
No, i have not such example (could it exists?), it was only to say that paren! or do was the same for foreach. paren! is usually faster than do block, so i should use paren! The main difference is that to paren! make a copy of the block, so it uses more memory, and if the user uses a reference to the block he can be fooled:
>> repeat i 10 collect-paren b: [if i > 5 [insert tail b [* 2]] i]
== [1 2 3 4 5 6 7 8 9 10]
>> repeat i 10 collect-do b: [if i > 5 [insert tail b [* 2]] i]
== [1 2 3 4 5 6 14 32 72 160] But changing an executed block is not safe in general. So i am not sure about the best solution. I vote for to paren! :-) --- Ciao Romano