[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: [ANN] Lua 5.4.0 (alpha) now available
- From: Dibyendu Majumdar <mobile@...>
- Date: Fri, 21 Jun 2019 22:47:37 +0100
On Fri, 21 Jun 2019 at 21:35, Andrew Gierth <andrew@tao11.riddles.org.uk> wrote:
>
> >>>>> "Dibyendu" == Dibyendu Majumdar <mobile@majumdar.org.uk> writes:
>
> Dibyendu> 1) Adding a 'toclose' variable in the 'for' loop is an
> Dibyendu> undesirable feature in my opinion. Not aware of any language
> Dibyendu> that does that.
>
> You do realize that this is one of the primary reasons for 'toclose' to
> exist at all? The fact that breaking or erroring out of a loop doesn't
> give the iterator any chance to clean up is a significant problem (for
> example, if iterating over io.lines, the file is not closed until it is
> GC'd, which may not happen until much later).
>
Not sure I understand ... no language I know has this, and yet many
have autoclosing of resources, so clearly it is not the reason for
toclose.
You would simply write:
with <var> = <initializer> do
for ... do
end
end
This is what you would do with any other language that supports this construct.
I haven't tried to articulate why this is bad, but here are two points:
1) In my opinion the acquiring of a resource and its auto closure
should be a visible thing.
2) The for loop construct seems a complete random thing. Why not then
do the same in if construct? Or repeat construct?
Regards