[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Basic question about modules
- From: Mark Hamburg <mark@...>
- Date: Tue, 5 Oct 2010 19:33:17 -0700
On Oct 5, 2010, at 4:33 PM, Nilson wrote:
> Why not a "syntactic sugar" like:
>
> "local M.exportedFunction1 = function() end" or "local
> M.exportedFunction1 () end"
>
> meaning
>
> "local exportedFunction1 = function() end; M.exportedFunction1 =
> exportedFunction1" or vice-versa?
>
> And finally, " return M "
>
> That would allow you to declare the function name only once but would
> create automatically a local function variable for a faster data
> access and also would reduce the typing effort of variables names and
> of the return statement.
That's a really interesting idea for syntactic sugar and it makes module building quite straightforward. Of course, it is misleading in that:
local M.name
--- code
name = "foo"
sets the local but not the value in M (and M.name = "foo" would do the opposite).
Mark