lua-users home
lua-l archive

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


Daniel Silverstone wrote:
>> It does raise the question of whether
>>   type(...)
>> should return a value?

> ...
> so type(...) would return the type of the first unclaimed argument in a
> new-style vararg function.

Right. If the enclosing chunk has no arguments then type(...) is the
same as type(). And that is exactly what happens.

> type(...)
stdin:1: bad argument #1 to 'type' (value expected)
stack traceback:
        [C]: in function 'type'
        stdin:1: in main chunk
        [C]: ?
> type()
stdin:1: bad argument #1 to 'type' (value expected)
stack traceback:
        [C]: in function 'type'
        stdin:1: in main chunk
        [C]: ?

It's easier for me to understand ... as a token in the language, not a
predefined variable.

Another example:

> function t(...) print(type(...)) end
> t(5)
number
> t()
stdin:1: bad argument #1 to 'type' (value expected)
stack traceback:
        [C]: in function 'type'
        stdin:1: in function 't'
        stdin:1: in main chunk
        [C]: ?


Doug

-- 
--__-__-____------_--_-_-_-___-___-____-_--_-___--____
Doug Rogers - ICI - V:703.893.2007x220 www.innocon.com
-_-_--_------____-_-_-___-_--___-_-___-_-_---_--_-__-_