Re: Implicit casting issues when binding to C++

  • From: Kaj Eijlers <bizziboi@xxxxxxxxx>
  • To: luajit@xxxxxxxxxxxxx
  • Date: Sat, 7 Jul 2012 10:26:28 -0700

>>Actually it could be good enough for production even. You use those fancy
casts mostly in complex GUI code where the compiled speed is not that
important.

Well, that's in this specific case, but once one can use C++ FFI I am sure
the floodgates will open and people will also want to bind stuff that sees
usage in more critical loops, so that doesn't seem a valid conclusion to me?

>> And you can instruct your users to avoid implicit constructors
by  explicitly specifying them (i.e. write QLabel(QString("Text")) instead
of QLabel("Text")) wherever the speed is essential. This will effectively
lift the cast out of the lj_cconv_ct_ct function into the Lua code.

That, again, to me seems incredibly unworkable. Implicit casts are a
conventience in C, in a scripting language you'd definitely not expect a
user to have to think about them. The end result would be that, to be on
the safe side, you'd do proper casting everywhere and the type conversion
has become obsolete because of it's own limitation. So the mere fact that
it exists makes it a hazard to its own existence?

Just my two cents - I am incredibly impressed with what you did.

Kaj

Other related posts: