lua-users home
lua-l archive

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



On Thu, Mar 7, 2019 at 1:01 PM Magicks M <m4gicks@gmail.com> wrote:
I will try to elaborate on what I meant in my previous statement. 

The concept I am referring to is the absence of a value, I'm not using concept to talk about something discussed in the manual or defined by lua necessarily. Just an abstract idea.

I did not intend the phrase "intangible second class value" to be read as hyperbole, perhaps I owe an explanation to my wording. 

Let's look at a very simple function declaration: 
function f(x) 
   return  x
end

If I call it f()  what is x? The answer is nil, but this is the same when we call f(nil). When we are just considering a pure lua function there is no way to know how f was called. There is no lua value to represent the difference. This to me satifies the definition "unable to be touched; not having physical presence." (intangible). Second class because we have to go through the process of using select with a vararg.

It is not good enough just to say that missing arguments are nil.
 
I do agree with you here, I was simply suggesting that removing this "missing", such that we couldn't use a roundabout method to check, would be more in line with lua's design as a whole.
I would be in favour of a value in lua to distinguish the two cases and not actually removing it though. Either way a proper mechanism or none at all is what I think is needed.

Lua's concept of a thing with no value is nil.

This "missing" idea is not a thing with no value. It is not the absence of value. It is the absence of a thing in its entirety, which -- if interpreted as a thing -- has no value.

As such, select('#') is not a hackish workaround but in fact the CORRECT, clean way of doing this. In your example x is in fact nil. There is no concept by which x is not nil. x is a thing, and it has no value. There isn't anything "missing". Rather, argument lists are a separate concept. An argument list is a thing. It is a thing that has a defined value. That defined value is a list with a specific length. That length is, in your example, zero. The difference between f() and f(nil) is not in the value of x, but in the length of the argument list. 

/s/ Adam