[Haskell-cafe] Comments and suggestions on code
Jonathan Cast
jonathanccast at fastmail.fm
Sun Jan 13 00:39:10 EST 2008
On 12 Jan 2008, at 4:42 PM, Andre Nathan wrote:
> On Sat, 2008-01-12 at 16:00 -0800, Jonathan Cast wrote:
>> Wait, the last entry? If you're just printing out the values, then
>> no --- those should have been garbage collected already.
>
> Won't they be garbage collected only after the last entry is used,
> though?
No. A cell is generated once either (a) it, or (b) a cell earlier in
the list, is required. A cell is garbage collected once both (a) it,
and (b) all cells earlier in the list, are no longer required. So if
you process the list strictly sequentially, it will be generated and
garbage collected sequentially.
> Since getDirectoryEntries returns a list, won't its elements
> have to be kept until the list is not used anymore, i.e., after the
> last
> entry is processed?
jcc
More information about the Haskell-Cafe
mailing list