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

  • From: Duncan Cross <duncan.cross@xxxxxxxxx>
  • To: luajit@xxxxxxxxxxxxx
  • Date: Tue, 31 Jul 2012 15:19:46 +0100

On Tue, Jul 31, 2012 at 3:03 PM, Coda Highland <chighland@xxxxxxxxx> wrote:
> On Tue, Jul 31, 2012 at 3:27 AM, Fjölnir Ásgeirsson
> <fjolnir@xxxxxxxxxxxxx> wrote:
>> Well no. It pcalls, and catches the error. That can't possibly be as fast as 
>> just calling dlsym straight. (which is how you check for symbols at runtime 
>> => I'm not sure what the issue is)
>
> Mike Pall said just a few e-mails ago that pcall is extremely cheap,
> and it's free if it gets JIT-compiled.

Look again - he clarified that this is only true if the code getting
pcall-ed completes normally (i.e. the first return value of the pcall
is true), and not if an error is involved, which is "very expensive on
some platforms".

-Duncan

Other related posts: