lua-users home
lua-l archive

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

2018-07-16 3:10 GMT+02:00 John Belmonte <>:
> On Sun, Jul 15, 2018 at 10:43 PM, Pierre Chapuis <>
> wrote:
>> I kind of agree that something like "with" could be useful in Lua. In my
>> opinion one way to do it would be to have a construct which forces garbage
>> collection of the variables created when exiting the block. This way cleanup
>> would be left to the `__gc` metamethod, but it would be deterministic. The
>> advantage would be that it would also work with code that already uses the
>> `__gc` metamethod as a cleanup possibility.
> Lack of an implementation strategy is not the obstacle to getting scope hook
> support into the Lua language.  There were plenty of proof-of-concept
> implementations 10 years ago.  (Using GC is not the preferred method, but
> that's besides the point.)
> The challenge is convincing the Lua authors that this kind of feature is
> worth adding to the language.

The original post bandied Python as a language that has the desired
feature. On Ubuntu 16.04, Python 2.7 has an executable of 3492656
bytes, stripped; Python 3.5 has 4464400, ditto.

By contrast, Lua 5.3.5 has an executable of 257376 bytes, not stripped,
and Lua 5.4.0 (work2) 279400.

Let's compare the two languages on the same input.

$ lua
Lua 5.3.5  Copyright (C) 1994-2018, PUC-Rio
> bloat = 4464400/279400; print(bloat)
$ python
Python 2.7.12 (default, Dec  4 2017, 14:50:18)
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> bloat = 4464400/279400; print(bloat)

I'm willing to accept that the Lua authors may feel that the 'with'
feature is not important enough to 99.5% of Lua users to justify
reducing Python's bloat factor.