I think HipHop for PHP is an interesting tool. It essentially converts PHP code to C ++ code. Cross compiling in this way seems like a great idea, but I need to wonder how they overcome the fundamental differences between the two types of systems? One specific example of my general question is heterogeneous data structures. Statically typed languages are not inclined to put arbitrary types in an array or other container, because they must be able to define types at the other end. If I have a PHP array like this:
$mixedBag = array("cat", 42, 8.5, false);
How can this be represented in C ++ code? One option would be to use void pointers (or an improved version, boost :: any), but then you need to discard when you retrieve the material from the array ... and I'm not at all sure that the inferencer type can always figure out what to throw at the other end. Most likely, the best option would be something like a union (or boost :: variant), but then you need to list all the possible types at compile time ... perhaps, perhaps, but, of course, randomly, since arrays can contain arbitrarily complex objects.
Does anyone know how HipHop and similar tools that go from a dynamic typing discipline to a static discipline deal with these issues?