Unhinged Ramblings.

The Description. It describes. A blog. My blog. I blog. Here.

Wednesday, June 27, 2007

Things I wish c++ could do.

I feel that the new c++ spec was largley a waste of time. When it was released I was filled with hope. The interveneing 10 years have made me bitter, very bitter. Instead of wasting their time on the acedemic improvement of the language, they could have spent some time giving use "useful" features.

1. functions as variables. Scripting languages like lua have it made. functions are treated as first class variables and can be freely reassigned and passed around. c++ has function pointers, but you just cant do the kind of stuff that you can when all function names are implicitly function pointers!

2. The ability to assign 'this'
this = (CMySelf*)pvParam;
Good grief. Static class members are one thing, but please let us actually assign the this pointer when we figure it out, and subsequently access class members.

3. forward inheritance of pure virtual methods.
Templates were an ok idea I guess and allow some neat generic ADT classes to be built. I dont belive they are the right solution for the problem of how to provide a base class that implements IUnknown.

All I want is a nice, non template based syntax, that lets me say

class CUnknownImpl : public IUnknown;
class CDispatchImpl : public CUnknownImpl, public IDispatch;

without the compiler getting all snarky about IDispatches' IUnknown methods being pure virtual when I clearly have provided #*%&ing implementation!

4. Writable vtables.
Why are vtables the only unwritable members of a class? This goes hand in hand with point #1. Virtual functions should be first class variables. Do all the method signature checking needed, but the ability to directly manipulate which implementation a particular vtable member points to at runtime would be damn sweet and save a lot of redundant framework effort.

5. Who screwed up void**?
In C, a pointer to a pointer to something can implicitly be converted to a void**. In c++ we have to have an explicit cast. What safety has been added by this requirement? Now, every call to QueryInterface needs a (void**)&pInterface. C has the type safety advantage here as it can at least check you have the correct level of indirection.

0 Comments:

Post a Comment

<< Home