[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: '__iter', yet again!
- From: Cosmin Apreutesei <cosmin.apreutesei@...>
- Date: Wed, 16 Dec 2009 22:48:42 +0200
On Wed, Dec 16, 2009 at 22:21, Petite Abeille <petite_abeille@mac.com> wrote:
>
> On Dec 16, 2009, at 9:08 PM, Cosmin Apreutesei wrote:
>
>>> f( 'foo', nil, 'bar', nil )
>>
>> That n is exactly what I would've scrapped.
>
> You cannot just scrap that as it tells unpack how long your list of argument is. Without it, you could never properly unpack arguments with nils.
>
> Consider:
>
> print( #{ 'a', nil, 'b', nil } )
>
>> 1
>
> Therefore:
>
> unpack( { 'a', nil, 'b', nil } ) would pass only the first parameter if not told otherwise.
>
> So:
>
> f( 'a', nil, 'b', nil ) != f( unpack( { 'a', nil, 'b', nil } ) ) = f( 'a' )
> f( 'a', nil, 'b', nil ) = f( unpack( { 'a', nil, 'b', nil }, 1, 4 ) )
>
Ugh, yes, you're right, I got that part out of a larger context[1]
where in my mind # was also defined for sparse arrays. Sorry for the
confusion. I'd still make f() equivalent to f(nil) even without the
alignment of varargs and arrays length.
[1] http://lua-users.org/wiki/CosminApreutesei
- References:
- Re: '__iter', yet again!, Luiz Henrique de Figueiredo
- Re: '__iter', yet again!, steve donovan
- Re: '__iter', yet again!, Javier Guerra
- Re: '__iter', yet again!, Mark Hamburg
- Re: '__iter', yet again!, Cosmin Apreutesei
- Re: '__iter', yet again!, Petite Abeille
- Re: '__iter', yet again!, Cosmin Apreutesei
- Re: '__iter', yet again!, Petite Abeille