Key object implementation as a Union with operators

Probably just showing my ignorance here (self-taught programmer), but I was surprised to find the definition of the Key object in Kaleidoscope was via a union of the ‘object-data’ and operator definitions. I didn’t realise you could dereference a this pointer in a union, and thought of a union as storing only one of its members at a time. I guess it works because it doesn’t need to store the operator definitions, since the symbol definitions get compiled into some global vtable. Pretty nifty, but my question is, why not use a normal C++ class? Is it because the language is not actually C++ (in which case, what is it?). Or is this something one does in embedded programming because it avoids some of the overhead of the full C++ class system?

It was originally a union without operators. When we added the operators, we kept it as a union, because why not? It’s still simple, simpler than a class would be (in my opinion, at least), and gets the job done.

It is C++ with some additional typedefs and libraries and without a main(...) function.

Nice! I like it! Learn something new every day.

Unions are a bit strange as they are kind-of classes.

From the C++ standard:

9.5 Unions
A union can have member functions (including 
constructors and destructors), but not virtual (10.3) 
functions. A union shall not have base classes. A 
union shall not be used as a base class.