lua-users home
lua-l archive

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


> On 26 Jun 2018, at 13:13, Kenneth Lorber <keni@his.com<mailto:keni@his.com>> wrote:
> 
> On Jun 23, 2018, at 8:57 AM, Andrew Gierth <andrew@tao11.riddles.org.uk<mailto:andrew@tao11.riddles.org.uk>> wrote:
> 
> [...]
> To me it is about flexibility, multiple return values, and the ability to only take what is needed. Eg:
> 
>    take_two(return_three())
> 
> 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:
> 
> https://github.com/Kong/kong/blob/82a51c4b519728eed4f957fdaa547ed4abea9332/kong/globalpatches.lua#L296-L302
> 
> 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.
> 
> Thijs

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.

Thanks,
Keni