[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Suggestion to Lua
- From: Mike Cuddy <mcuddy@...>
- Date: Tue, 18 Apr 2000 14:27:35 +0100
> I like this suggestion, though we could just set a certain
> global by convention and get the same result. Having an API
> might help force the convention, but it complicates the language
> a bit.
In the scripts that I've written, I've just exported an "ERRNO" type
variable which gets set on failure by the native function (but NOT touched
Setting the global to '0' in the runtime is a bad idea. You have to 'ping
pong' the variable (saving the old state), so that a C function to deal with
errors can get the state (if making a native call automatically clears
the variable, you can't use the error state in a native call without saving
it, thereby adding (small) overhead and decreasing flexibility.
It's the UNIX 'errno' model: it's only SET on an error. If you want to see
if it gets set, you explicitly set it to 0 in your program.
Mike Cuddy (mcuddy@FensEnde.com, MC312), Programmer, Daddy, Human.
Fen's Ende Software, Redwood City, CA, USA, Earth, Sol System, Milky Way.
I remember asking why ... Let it rain, and protect us from this Cruel Sun.
Join CAUCE: The Coalition Against Unsolicited Commercial E-mail.