lua-users home
lua-l archive

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

On Jun 27, 2018, at 9:51 AM, wrote:

Date: Wed, 27 Jun 2018 12:06:41 +0000
From: Thijs Schreijer <>
Subject: Re: require() parse error in 5.3.4/5.4.0-work2?
To: Lua mailing list <>
Message-ID: <>
Content-Type: text/plain; charset="utf-8"

On 27 Jun 2018, at 13:15, Kenneth Lorber <> wrote:

On 26 Jun 2018, at 13:13, Kenneth Lorber <<>> wrote:

On Jun 23, 2018, at 8:57 AM, Andrew Gierth <<>> wrote:

To me it is about flexibility, multiple return values, and the ability to only take what is needed. Eg:


Without a bunch of locals. Why would you even want to limit that and make it an error? It takes flexibility away.

For example: take OpenResty, it uses a lot of those extra checks and it's a pita. See this code for example:

The last argument “socket options” must be a table, not even `nil` is accepted. Hence in the calling code it requires an if-then construct.

So be careful what you wish for with those checks.


I was going to just let this go, but the replies are getting so far afield I just can't.  I'm not asking about the language feature in general, or about function prototypes, or  user written code or any of the other things people have brought up.

I'm talking about the basic, lua-distribution-supplied functions such as require.  So let me rephrase my original questions and we'll just stick to require only:

Is there some reason accepting     require("file", "ignored argument")     is a language feature?  Some use-case I don't see?  (If so, why is there the occasional check for extra arguments?)

Is it documented somewhere I missed that lua functions supplied by the distribution accept and ignore extra arguments?

Is there any reason not to add checks for extra arguments to the functions supplied by the lua distribution?  If it's performance, it could be available as a compile time option.

I hope this gets the discussion back on track, whether anyone agrees with me or not.


The way I see it, Lua tries to be as “unspecific” as possible, as in that the global environment itself is just a table for example, as are all libraries, and the registry, and every global can be redefined by a Lua version.

In your example `require` is just a function, as any other Lua function. With your proposal you’re defining “Lua defined functions” and “language defined functions” as separate types/behaviours. Why this complication?


Since we are clearly not communicating effectively, let's try this from another direction:
> math.random(3,4,5)
stdin:1: wrong number of arguments

> t={}
> table.insert(t,1,2,3,4)
stdin:1: wrong number of arguments to 'insert'

Are these bugs that should be fixed in Lua?