Re: ffi idea: strip null pointers

  • From: Jay Carlson <nop@xxxxxxx>
  • To: luajit@xxxxxxxxxxxxx
  • Date: Mon, 4 Jun 2012 16:57:50 -0400

On Jun 4, 2012 1:45 PM, "Joshua Day" <josh.day@xxxxxxxxx> wrote:
>
> Mike Pall wrote:
> > Cosmin Apreutesei wrote:
> > > Isn't there a speed loss on any of the many automatic conversions that
> > > the ffi does between C and Lua types?
> >
> > Not really.
> >
> > [A special case is 'bool'. But then you probably want to branch on
> > that, or you wouldn't use a bool. There's special logic to avoid
> > the overhead, if you don't use the result.]
>
> It seems that Cosmin wants to guard against NULL without any more
> syntax than is necessary for the Lua-native case, and it's hard to
> blame him.

I got burned by this with an assert() function. And with an iterator--a C
GetNext function signalled EOF with NULL and I figured, "perfect, that's
what 'for' expects."

Making NULL false-y or nil-y is one answer. Letting the C FFI suck (and
suck strictly more than C itself) is another, but I expect a mid-level wrap
layer based on experiences with the FFI might be a good idea for
escape-from-C-weenies like me.

Jay

Strong authentication just proves which chump is in front of the keyboard.

Other related posts: