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

  • From: Cosmin Apreutesei <cosmin.apreutesei@xxxxxxxxx>
  • To: luajit@xxxxxxxxxxxxx
  • Date: Wed, 1 Aug 2012 10:52:23 +0300

So in the end, wouldn't it be easier/cleaner/more Lua-like to return
nil for missing symbols than raise and exception and forget about all
these pcall/dlsysm/getprocaddress hacks? After all, this is how Lua
behaves for normal modules and nobody seem to mind. And you could
always wrap a ffi module with a proxy table if you want error checking
ala strict.lua.

The only objection I heard so far to this is symbols which resolve to
null but can someone confirm that they actually resolve to nil and not
null cdata? And even if they were, I don't see a problem with that
ambiguity anyway.

Other related posts: