[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Lua C API
- From: Jim <djvaios@...>
- Date: Wed, 22 May 2019 21:12:41 +0200
On 5/17/19, William Ahern <william@25thandclement.com> wrote:
> While the Lua C API has some unpleasant artifacts from incremental
> improvements, it's actually much nicer than you seem to give it credit for.
> And in my experience much nicer thanh the vast majority of APIs I've run
> across.
here is an example from the SGScript(.org) documentation:
http://www.sgscript.org/pages/advdocs/sgscript.docs.htm#Argument-handling
used in
if ( sgs_LoadArgs ( "s|f", & str, & q ) ) return 0 ;
sgs_LoadArgs() does type-based argument parsing
's' requires a value that can be converted to a string, returns to
passed char**
'f' requires a value that can be converted to a real value, returns
to passed float*
'|' makes all arguments after it optional (always initialize data
passed to those!)
there are many more options and features for this function
Squirrel provides similar functionality (look it up yourself in its docs).
this is just an example to show what other languages' C APIs provide.
BTW:
it is still not clear to me what a negative return value from a call to a
Lua C function like "int cfunc ( lua_State * L )" means/represents/is used for.