lua-users home
lua-l archive

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


Op Do. 27 Jun. 2019 om 13:08 het Dibyendu Majumdar
<mobile@majumdar.org.uk> geskryf:

> In some ways an ugly syntax for 'toclose' declarations is not a bad
> thing, as they draw attention of the reader to the fact. Also explicit
> declarations are important for the same reason, and that is why I
> think performing automatic close() in a generic for loop is not a good
> idea as the reader of the code can't tell what is potentially
> happening behind the scenes.

I've been a Lua user for almost ten years, and I've succeeded in
understanding and sometimes using every language addition in that
time. Not so with <toclose>.

My perceptions about it are:

1. It solves a problem encountered by a very small fraction of Lua users.
2. Although it looks like a property of a variable, i.e. a name, it is
a property of the associated value.
3. All variables declared <toclose> must have a metatable with a
__close metamethod, otherwise nothing different happens anyway.
4. Therefore they must be either tables or full userdata.
5. The 5.4 alpha syntax for it is the least ugly among various
possibilities, but still ugly.
6. It runs counter to Lua's design goals of being minimal, neat and compact.

In other words, <toclose> is feature bloat.

> However the ugly syntax for a constant declaration is the side effect
> of this; and that is a heavy price to pay. Given that the constant
> feature seems to have been added because it was 'free' - perhaps, it
> shouldn't be added to the language.

Agreed.

-- Dirk