Re: Implicit casting issues when binding to C++

  • From: Mike Pall <mike-1207@xxxxxxxxxx>
  • To: luajit@xxxxxxxxxxxxx
  • Date: Wed, 11 Jul 2012 21:45:27 +0200

Janis Britals wrote:
> BTW, what do you think of the __tonumber metamethod I mentioned in my last
> post? That would go a long way towards sorting the enum mess.

I have to think about it. I should really check the C++ specs on
what's allowed with enums and what's not.

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).

You can already use tonumber() on a boxed enum value to force the
conversion. And allocation sinking should eliminate most of the
remaining boxes.

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

Undecided (yet).

--Mike

Other related posts: