3.17.2011

Deleting

I had a creative highlight last night and got a quite nice and convincing RTTI implementation of minimalistic functionality working. Unfotunately, there's a problem with deleting random object that could have any type possible. I have a single delete function for each RTTI-wrapped class I can call by retrieving a reference to the object's RTTI structure (Oh and I made the assignment operator private, so you can't overwrite it but keep it possible to access methods from there. Quite comfortable.). But the problem I have so far is that this function works like delete - it deletes the passed address. So I can't just put it into the destructor of a random object because it can't delete itself. So I thought about globally overloading (or atleast in it's namespace) the operator for RandomObject types to ensure that I can delete in the way I want. And that's the problem itself, delete only works with void* and I you can't do anything about it. To ensure that an object get's deleted properly without knowing it's type during compile time, you have to enable C++' RTTI, making the whole thing pointless. I would love to call constructors on my own, but that's also not possible.

I'm again stuck with a stupid "feature" of C++. Fine. Just fine. Sometimes I think it's besser to totally drop all C++, but then again I can't find any alternative or even want to rewrite everything I've accomplished so far. It sucks, totally. And again, it's something I can only implement in my own language. ARGH, STUFF'S PISSING ME OFF. Oh man, this language sucks in so many points. I would've have been better to not implement it in an "either this or not" way. However, I can still implement my own function outside the class and make it avaible, namespace-wide. So there's atleast one way to keep possible to delete objects depending on their real type. Hm, no, this does also not work... I can't make it a normal function as C++' still allows to implicitely cast to a base cast and thus it may be ambigous what function to call. So I guess I can't do anything about it. Writing x->rtti().deleteObject(x); instead of delete x; is inconvenient.

No comments: