Re: Implicit casting issues when binding to C++

  • From: "Janis Britals" <jbritals@xxxxxxxxx>
  • To: luajit@xxxxxxxxxxxxx
  • Date: Wed, 11 Jul 2012 23:07:15 +0200

Mike Pall wrote:

> Maybe I should drop the automatic enum -> int conversions for loads?
> Instead box all enum values and unbox and/or convert them only
> when needed (for stores or when passed as an argument).

This would be the ideal solution for C++ bindings. Also because the
current implicit "string"->enum conversion is not that useful for C++
enums, not until you introduce namespaces for ctypes.

> Existing code that has C functions returning an enum might need to
> wrap some of these calls into tonumber() then.

This probably would feel a bit awkward for C programmers who are used to
regarding enums as equivalent to const int. Maybe you could introduce a
mode switch: C <-> C++ that would determine things like enum semantics?
Just my two cents.

-- Janis

Other related posts: