[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: [ANN] Lua 5.2.0 (work4) now available
- From: Miles Bader <miles@...>
- Date: Mon, 02 Aug 2010 11:44:44 +0900
phlnc8 <phlnc8@gmail.com> writes:
> import my_module
> for
> local my_module = require 'my_module'
>
> I know this has already been proposed and discussed on the list, but
> given this new module policy, wouldn't it make even more sense?
What's the real point though? You typically only have a few such
"imports" in any file, so the reduced typing isn't important, and the
explicit version ("local x = require(...)") has some advantages --
1. It's more clear what it's actually doing, and yet it's still
concise and understandable.
2. It lets you choose a different variable name than the external
module name, which is often very convenient when the module author
used something a little too verbose.
3. It lets one use the same construct for slightly funnier cases, e.g.,
when you don't actually want to use require for some reason.
4. Less feeling of "magic"
I'd say the syntax sugar isn't needed, at least for this case.
-Miles
--
Do not taunt Happy Fun Ball.