[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: LUA_USE_APICHECK
- From: Josh Simmons <simmons.44@...>
- Date: Fri, 26 Aug 2011 21:03:05 +1000
On Fri, Aug 26, 2011 at 8:54 PM, Axel Kittenberger <axkibe@gmail.com> 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.
>
>
The bit about given an acceptable index is a precondition for the
entire sentence, none of the rest of it has any meaning if you don't
supply an acceptable index. This follows from the API not checking
consistency of API calls, if it were to return null on invalid indexes
that would require checking the arguments for validity.
I'm going to say it again because it seems like it's not getting through.
"If the value at the given acceptable index" explicitly implies that
you've given an acceptable index to the function. Reading into the
rest of the sentence serves no purpose because you have not met this
precondition.
If somebody can come up with a more easily comprehended text though, I
suppose this shows that would be useful.