lua-users home
lua-l archive

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

On Oct 18, 2011, at 10:27 PM, Krunal Rao wrote:

> In a sense I would phrase the question as: what is wrong / needs to be
> improved with the approach I mention above that requires additional
> code / functionality?

Well... just about everything that module offers today... so... given the outline under "15.4 The module Function":

1: local modname = ... 
2: local M = {} 
3: _G[modname] = M 
4: package.loaded[modname] = M
5: setfenv(1, M)

That would be 1, 2, 4 & 5. 

Other functionalities such as "reopening a module already created" a la Objective-C category is handy as well.

Systematically setting _M and _NAME is welcome also, practically speaking.

In short, all the functionalities of module circa 5.1  (short of messing with _G).

Lua 5.2 value proposition is: stick to the basic form and wave goodbye to anything more sophisticated out-of-the-box. 

That basic form is, well, way too basic. The word trivial has repetitively being used to describe its usage. Indeed. Trivial in use and trivial in functionality.  

There is a counterpart to the oft quoted Saint-Exupery bon mot:

"A designer knows he has achieved perfection not when there is nothing left to add, but when there is nothing left to take away. "

It's Albert Einstein's one:

"Everything should be made as simple as possible, but not simpler. " 

With the deprecation of module, I personally feel that the line has been crossed from simplification to trivialization.