lua-users home
lua-l archive

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


2010/7/14 Quae Quack <quae@daurnimator.com>:
> On 14 July 2010 12:54, Kevin Vermeer <reemrevnivek@gmail.com> wrote:
>>
>> which is useless for the point of this section of the documentation.  Eike's
>> code:
>>>
>>> local pos = 1
>>> for i=1,#arr do
>>>   if arr[i] ~= nil then
>>>     arr[pos],arr[i],pos = arr[i],nil,pos+1
>>>   end
>>> end
>>
>> on the other hand, performs a useful function, and is best expressed with
>> the multiple assignment statement.
>>
>> --
>>
>> Kevin Vermeer
>>
>>
>
> is it?
>
> arr [ pos ] = arr [ i ]
> arr [ i ] = nil
> pos = pos + 1
>
> seems fine to me....
>

Of course, and that is pretty much how I "unrolled" it. But
nevertheless I was curios about the exact behavior. I was not yet
aware that uncovered behavior in the manual is indirectly also
undefined behavior - a statement with which I can live and that I
understand. If the documentation would cover everything, it would be
way too huge and as pointed out, being an obstacle for future changes
(though I do not believe that downward compatibility is working
properly in programming language environments - either because it
makes innovation impossible or it may end up with obscure
specifications that can only be historically explained).
Nevertheless: The example I gave was extracted from "real" code - it's
not artificially made up unless for explanation. So I thought it's a
valid question to ask and in fact, something that I found quite
interesting to ponder about.

Eike