[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: string.byte with empty string
- From: Alexander Gladysh <agladysh@...>
- Date: Sun, 25 Jan 2009 00:37:41 +0300
On Sun, Jan 25, 2009 at 12:30 AM, Peter Cawley <email@example.com> wrote:
> On Sat, Jan 24, 2009 at 9:08 PM, Alexander Gladysh <firstname.lastname@example.org> wrote:
>> In Lua "to return zero values" is the same as to return nil.
> No, they are not the same. The number of return values from a function
> call is corrected to number of results which the caller is expecting
> either by appending nils, or truncating the last value(s). In many
> contexts, like assigning the results of a function to variables, or
> performing a table index on the result of a function, the number of
> results is set explicitly by the caller. In other contexts, like the
> end of an argument list for function calls and table constructions, no
> appending or truncating is done.
> Hence the visible behaviour of returning zero values is the same
> visible behaviour as returning nil, in certain contexts. In all
> contexts, the non-visible behaviour is different, and in some
> contexts, the visible behaviour is different.
Wow. You're right.
Lua 5.1.4 Copyright (C) 1994-2008 Lua.org, PUC-Rio
> f = function() end
stdin:1: bad argument #1 to 'type' (value expected)
[C]: in function 'type'
stdin:1: in main chunk
> ff = function() return nil end
I didn't know this.