lua-users home
lua-l archive

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

> On Jul 5, 2019, at 16:24, Coda Highland <> wrote:
> I mean, yeah, I don't think angle brackets are an ideal syntax for it, and "toclose" is something of an awkward name, but everything else about it I think is sound.

Not sure where to stick these comments, so instead of starting another thread...

<toclose> solves a problem I’ve actually had: getting rid of a big resource in a deterministic way, regardless of error, not waiting for __gc. Since this solves that problem in a way I can understand, thumbs up!

Making a wild guess: in 10k lines of code, I may use something like this in 5 places, almost always in library code, not application scripts. I don’t mind it being verbose or even a little awkward. Some may argue that the syntax should stand out and be overly clear (no multiple assignments that might make order of release slightly ambiguous or at least something I may have to look up). When handling resources and memory, I like to go slow and careful because I make lots of mistakes. 

As for the word, “close” makes sense enough to me because that’s what I care about (and release is a longer word to type). I don’t care that the tiny little variable is garbage collected. I care that the big giant resource that the variable is holding on to is closed/released as soon as possible. 

This looks like a nice enough mechanism to do that. 

I’ve read most, but not all, of the debates around this. I have not gotten the sense that the controversy is because this doesn’t work for the intended purpose; just that it’s awkward or that people wished it worked differently / more flexibly. 

Does it solve a real problem that is worth solving? Does Lua 5.4’s <toclose> feature work for that intended purpose?  Does it break anything? Given its use cases, is it clear enough and does the syntax fit for the purpose?