lua-users home
lua-l archive

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


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.