Re: function to check if a symbol in a library exists or not

  • From: Cosmin Apreutesei <cosmin.apreutesei@xxxxxxxxx>
  • To: luajit@xxxxxxxxxxxxx
  • Date: Mon, 30 Jul 2012 10:11:44 +0300

Just wanted to mention another possiblity that I thought about but
then discarded:

local function proxy(lib, patt)
        return function(t,k)
                return lib[string.format(patt, k)]

ffi.metatype('cairo_t', {__index = proxy(lib, 'cairo_%s')})

I discarded this because it is slow and creates a string every time.
Memoizing the lookup result in t would solve the problem, but AFAIK
the ffi doesn't allow it.

Other related posts: