CSharp Optionally Dynamic Calls

I’ve been reading about how the C# team is considering putting the option to call dynamic code within C# directly and I have been looking at some of the syntax they have been proposing publicly. It also seems like there are a handful of people who are proposing their own ideas of how to express various features of C# they wish existed so I thought I’d propose one of my own.

Personally I find the idea of a dynamic method or a dynamic block a little clunky. So I would like to propose a different possible solution.

The whole idea is that in C# the compiler has to know the type of a variable so it can guarantee that the method you are trying to call exists. This is largely the purpose of interfaces. However, there are some circumstances where you might prefer to call a method dynamically. The dynamic method block syntax Charlier Calvert is proposing is very reminiscent of the “unsafe” synatx in C# however if you really wanted to make the language more dynamic in general I think you could simply have the option to call the memeber with something other than a ‘.’ to indicate that it should be a dynamic call. Something more like:

string example = obj:Example();

In this case I’m suggesting that merely replacing the ‘.’ with a ‘:’ will cause the application to call the Example method dynamically. I belive this would still conform to the explicit nature of C# while making dynamic calls quite flexible. If the colon was an undesierable character it would be simple enough to just use something else.

In this case you would not get much intellisense related to the parameters or return value of Example wich I believe would prevent it from being used except in circumstances where it was absolutely needed. Also you would only get runtime exceptions if the types of the parameters and return values were incorrect. It would probably have to assume that the return Type was actually an object if you used the “var” syntax.

Also, you would need some way to check to see if the member existed at the very least:

string example;
if(exists(obj:Example))
   example = obj:Example();

Of course, this should be essentially the same for fields, properties and events. For example:

string example = obj:Example; // field or property
obj:ExampleEvent += new EventHandler(OnExampleEvent);

Twin Cities Code Camp Spring 2008

I will be giving another talk at the next Twin Cities Code Camp about Visual Studio integration. The event is on April 5th and is free so you should definitely come down and make me sweat with questions that I cannot answer!

http://www.twincitiescodecamp.com/

I plan on talking about visual studio integration in general but I will hopefully show off the current state of the NBusiness 3 plugin as well.

XNA AI Talk

Tomorrow night (Thursday, 2/21/08) is the next XNA Twin Cities User Group meeting and I will be giving a presentation on the MinMax algorithm in Drop In. It should be pretty fun, there will be some pizza and swag (including some xbox games) and a few other speakers talking about some other interesting AI topics. If you’re in the area you should definitely stop in and learn about XNA!

Here is the main link http://www.twincitiesxnausergroup.com/

And be sure to RSVP so we can guage how many people will be there and get the appropriate amount of pizza.

Rockband and Homebrew Aftermath

So it turned out that my homebrew was undrinkable. It seems it had sat too long and suffered from a mild infection so I had to dump it out. Fortunately we had Surly Bender to the rescue! After thinking about it a little bit I headed out to Midwest Supplies and picked up some equipment to upgrade my keggerator to be compatible with both American Standard and Kornelius kegs. This is a pretty nice upgrade!

  

Actually there was on piece that didn’t quite work right so I have a little bit more work to go. The piece was a splitter that turned out to be a one-way splitter. It turns out that you can’t combine the flow with this splitter, you can only split it. So I had to do a temporary splice directly from the tap to the keg, but I will probably go back and get something like this 3/8” Stainless Steel Barbed “T” instead and save my self $30 in the process.
The beer was delicious and the food was good and we had some good friends come over and had some fun. There were a few people who I was hoping would show up but couldn’t for various reasons (you know who you are) so that was a little unfortunate. Otherwise we ended up playing Rockband until 3am (much to the dismay of my upstairs neighbors I’m sure) and then I had to kick people out so I could crash.
One last thing, I couldn’t resist going out and buying Scene It since I knew so many people were coming over. We played it in impromptu teams and it turns out that it is hard as hell. Don’t plan on buying this game for your kids because I’d be shocked if they knew half of the answers, it is really intended for the truly discriminating movie buff.  That aside it was pretty fun, we were a little perplexed by the big button controllers since the ‘X’ on them didn’t light up when you pressed it like regular xbox 360 controllers but it turns out that they are not truly blue tooth enabled controllers, they communicate via IR with a reciever that goes ontop of your TV. I don’t know why they went that rout… probably just being cheap. However I am looking forward to the next version of XNA which I heard will have drivers to allow you to use these controllers for your games.