lua-users home
lua-l archive

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


On Wednesday, June 04, 2014 05:15:23 PM Dirk Laurie wrote:
> More generally, "lexical void" inside an argument list could mean nil.
> That is something that I (when in a bikeshedding mood) have sometimes
> missed, with some library functions where I use seldom use the early
> arguments, e.g.
> 
> load(source,,,MY_ENV)

I like this. And on the left side too.

    first,,third = something()

Assigns the first and third values while dropping the second without having to 
assign a dummy variable.

> But now, in your example, I don't suppose you want
> to mean
> 
> print('this is a string', 'another string', 'yet another string', nil )
> 
> or would you?

You can have both. The formal definition of an unnamed element in a comma list 
is "nothing". That is, 

    print() -- is not the same as
    print(nil) -- thus
    print(,) -- is not the same as
    print(nil,nil)

It's not that you're ignoring the last comma when there's no variable after 
it, you're implying the last comma after a variable name. Then the number of 
arguments to the function is equal to the number of commas.

-- 
tom <telliamed@whoopdedo.org>