[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Why are Lua Modules Only a Runtime Component of the Language?
- From: Paul Bonser <misterpib@...>
- Date: Mon, 7 Mar 2011 09:19:27 -0600
On Mon, Mar 7, 2011 at 9:06 AM, Jon Akhtar <akhtar@mindspring.com> wrote:
> Is there a compelling reason for not making 'require' and 'module'
> keywords in the language.
Is there a compelling reason TO make them keywords?
>
> Since I am working on a static analysis tool for Lua, handling Lua
> modules is something I need to do. In doing so, I find myself
> continually nagged by this question of why modules have a second class
> status. Why is 'require' merely a function with the name 'require'?
For the same reason that classes aren't "first-class" in Lua, I'd say.
>
> The only reasons I can come up with is that modules (like almost
> everything in Lua) are optional, and may not be included in embedded
> Lua, and that they were built using lower level api's like setfenv.
Right, it seems to be the "Lua way" to include a simpler, lower-level
functionality that allows you to implement specific, higher-level
functionality, but not to force any specific implementation on you.
>
> That is fair enough. I was just wondering if adding the module system
> as a language (grammar) feature vs a library had been considered and
> if anyone had any additional insight on the matter.
It's part of the standard library, which is implemented in C. I would
say keeping the grammar as simple as possible is a pretty valuable
goal.
Why add something to the grammar when it works fine as a function? For
static analysis just assume that when someone says "require" or
"module" that they are using the standard functions. If they aren't,
they either know what they are doing or are asking for trouble anyway,
right? :P
>
> Thanks In Advance,
>
> Jon Akhtar
>
>
--
Paul Bonser
http://probablyprogramming.com
http://twitter.com/pib