Wednesday, October 14, 2009

undef

I implemented the "undef" keyword, and I am actually finding it quite useful. What undef does is to undefine a member definition that would otherwise be defined automatically. Originally I had planned on using this to remove inherited methods (it replaces the vtable entry with one that simply throws an exception), however I am also finding it quite useful for undefining the default constructor - that is, if you have a class which can only be produced via some external entity (such as a library), then you can undef the constructor which will prevent the compiler from creating a default constructor for that type. For example, all of the reflection types, which are only creatable by the compiler, have undefined constructors.

No comments:

Post a Comment