lua-users home
lua-l archive

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


Roberto Ierusalimschy wrote:
On Sat, Aug 7, 2010 at 9:50 AM, Petri Häkkinen <petrih3@gmail.com> wrote:
    
On 7.8.2010, at 6.10, Mark Hamburg <mark@grubmah.com> wrote:
      
This hardly seems particularly bizarre and it doesn't rely on tricks with
environment to change global assignments into exported values.

        
Indeed. Honestly this should become the recommended practice or the new
'policy', if you will. It's as explicit and simple as it gets.
      
Yes, much easier to explain to a newcomer.  _We_ may get module() but
it's a subtle sideways beast, with pitfalls as pointed out by David M.
 (We also tend to forget our initial puzzlement with module())

Also, it is invariant with respect to the 5.1 -> 5.2 transformation ;)
    
Just recently I rewrote the 're' module in LPEG to be invariant with
respect to the 5.1->5.2 transformation. I used a slightly different
technique. I declared everything local and only in the end I exported
what I wanted:

   local function foo1 ...
   local function foo2 ...
   local function foo3 ...
   ...
   return {
     foo1 = foo1,
     foo3 = foo3,
   }

-- Roberto


  
If local were the default, and items to be used elsewhere had to be exported, just think how many other problems would become basically impossible.

Everett L.(Rett) Williams II