I was hoping that the c++ output, at least, could look like a bit like 'real' c++, eg: this...
namespace mojo
class Image
class Frame
end
end
...could translate to...
namespace mojo{
class Image{
class Frame{
};
};
}
Alas, it's not that simple.
The main issue with nicely scoped c++ is that it turns out you can't 'forward reference' inner classes - at all! This is a new one on me, but one of the things I really like about monkey1 is how all the forward referencing issues you have in c/c++ just don't exist, and I want the same to be true of monkey2. So I have decided to abandon nicely scoped c++ output for now.
I was also hoping I could rely on c++'s function overloading to allow me to use the same function names for overloaded functions.
This mostly works, except when using overloaded member pointers. You can 'cast your way' out of the problem (see: http://stackoverflow.com/questions/4364599/c-overloaded-method-pointer) but that's pretty nasty. It's easier for monkey to just mung a new name for overloaded functions, so I've decided to go with that for now too.
So c++ output wont be as sexy as I'd hoped, but there is an upside to this: the translator is now much more 'universal' and will be easier to adapt to other target languages. This is probably what I should have aimed for in the first place.
The output WILL be cleaner than monkey1's though, mainly because, for now at least, I only have to write one translator! Having to write 5 at once was a killer, and the quality of each suffered.
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.