lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


It was thus said that the Great Paul Ducklin once stated:
> 
> >io.lines("file") now returns 4 values:
>  >readline_func, nil, nil, file where the readline_func
> >is a closure that returns the next line from the
> >file, and "file" is the filehandle that was opened,
> >which will be closed via its __close metamethod.
> 
> This is one of only two places in the whole Lua codebase, and is the only
> library function, where __close is used (in both cases the code just sets
> __close = __gc).

  Now that I think about it, why have __close at all?  Why not have locals
marked as <toclose> just call __gc upon leaving scope?  It is to avoid
possibly code breakage with for loops?

  -spc