lua-users home
lua-l archive

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


On 26 August 2011 14:13, Roberto Ierusalimschy <roberto@inf.puc-rio.br> wrote:
>> > The manual doesn't say that non-acceptable indices should return NULL.
>>
>> In my opinion it does.
>>
>> "If the value at the given acceptable index is a full userdata,
>> returns its block address. If the value is a light userdata, returns
>> its pointer. Otherwise, returns NULL"
>>
>> This english compiles into pseudo-code
>>
>> if valid(index) and valueat(index) == userdata then return block address
>> elseif valid(index) and valueat(index) == light userdata then return pointer
>> else return NULL.
>>
>> So an invalid index returns NULL.
>
> Of course, being English a natural language, practically any sentence is
> subject to multiple interpretations. But I, as a non-native speaker,
> would read that sentence like this:
>
> "If the value at the given acceptable index is a full userdata, returns
> its block address. If the value [at the given acceptable index] is a
> light userdata, returns its pointer. Otherwise [that is, both cases
> are false: the value at the given acceptable index is neither a full
> userdata nor a light userdata], returns NULL."
>
> -- Roberto
>
>

If that is the intention could I suggest that it either specifies that
an acceptable index is a pre condition of the function or changing you
words.
 "If the value at the given acceptable index is a full userdata, returns
its block address. If the value [at the given acceptable index] is a
light userdata, returns its pointer. Otherwise [that is, both cases
are false and the index is acceptable], returns NULL."

Liam