I know the answer (it's 42)

A blog on coding, .NET, .NET Compact Framework and life in general....

April, 2007

  • I know the answer (it's 42)

    Return to the native land


    I have heard about and experienced myself the fun/pain of transitioning into managed code from native. However, right now I'm going through the reverse phase. I'm coding in pure C++ after almost 3 years. Its not maintainence work but designing and creating new COM components that are used from managed and native code, which makes it all the more difficult.

    The feeling is kind of weird. I get the same macho-geeky feelings one gets when mucking around with COM pointers and weird ATL macros and fix memory corruption/leaks. But mostly I feel scared. I double check every allocation I make to ensure I have released them and feel helplessly out of Fx support.

    The funny part is that all the weird COM things which I desperately wanted to forget came back seamlessly. I have an advice for people working on COM. Bring up a text editor and code COM scratch up without any Fx support once. Manage all the ugly vtables, aggregation, dispatch tables yourself and then you'll never ever forget it. I think inside COM or one such books Essential COM takes the reader through this step and thats the one I followed and its helping me immensely now.


  • I know the answer (it's 42)

    What can enums derive from


    I thought I knew the answer but a discussion in the internal alias proved me wrong :)

    enum e1 : int
    enum e2 : Int32

    The first enum complies fine but the second doesn't. The reason is apparent from the compiler error message "error CS1008: Type byte, sbyte, short, ushort, int, uint, long, or ulong expected". It means that the C# compiler accepts only built in types. The reason is simply because one can define a class as follows

    class Int32

    In this case enum e2 : Int32 will be invalid. The compiler could've taken extra pains in ensuring that the .NET types are not overloaded but it'd have extra cost which the compiler guys didn't take.

    Thanks to Cyrus for the info. It's unfortunate that he has stopped blogging he used to be among my favorite bloggers.

Page 1 of 1 (2 items)