[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Lua library API design
- From: Asko Kauppi <askok@...>
- Date: Sun, 8 Jan 2006 21:48:27 +0200
Then again, in many cases s.a. SDL this inevidently leads to problems
turning sample C application code to work with Lua. If the C code
has (value != 0) checks or similar, they simply won't work.
It is nevertheless always better to adjust to the "native" look and
feel of a given language, if someone has a silver-bullet solution to
this, I'd like to hear. But I think there isn't.
Rici Lake kirjoitti 8.1.2006 kello 21.09:
I forgot to mention my favorite bugbear in API bindings.
C does not have a true boolean type, so it typically uses 0 and non-
zero integers. Given APIs typically either return 0/failure 1/
success or 0/success non-zero/error or 0/success -1/look in 'error'
for the error or...
That's a pain, and it should not be translated to Lua APIs. Lua
provides a clear mechanism for error returns (well, two of them if
you include the pcall convention). OS interfaces which simply
return the integer result are, in my opinion, un-Lua-like and
unnecessarily thin. (And as awkward as the original C interface.)