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

[REBOL] Re: Processing files / Any AWK users?

From: brett:codeconscious at: 19-Nov-2001 16:04

Hi Gregg,
> If I'm processing a file, by lines, thus: > > foreach line read/lines/with file rec-sep [ > > It appears that foreach doesn't call read on each pass, but I thought I'd > ask to see if anyone knows, for certain. I know you can modify the block > that foreach uses and it will see the changes, but I wasn't sure what
> occurs in this scenario. > > The real question, I suppose, is: Should I cache the return value from
> before using it with foreach, or is that unnecessary?
No foreach does not call read on each pass. Read returns a series which is then given to foreach as a parameter. By cache I assume you mean something like: the-lines: read/lines/with file rec-sep foreach line the-lines [...] You would only do this if you need to access those lines again in your script. I doubt there is any other memory effect other than creation a single word "the-lines" and the prevention of the series being garbage collected. No opinion on the second question due to lack of knowledge :) Brett.