Duck Typing for .NET!

For structural typing fans (and they'll be more of you over time -- trust me), David Meyer has posted a duck typing library for .NET. There are many reasons this is cool, but in summary, it allows for many of the dynamic features of languages like Python and Ruby to used used in any .NET language. Very cool.


Comment Feed 1 comment on this post

Eirik Mangseth:


Isn't this the main principle behind Smalltalk, i.e. message based programming? In Smalltalk you don't really care about the type of an object, only what messages it understands. As an aside, the messages an object understands defines a protocol, which is exactly what interfaces defines as well. Just wish the Java designers had called them protocols instead of interfaces. You also need protocols in a single inheritance language to circumvent having one mega big ancestor for all your classes, present and future.

Example: Let's say you're going hiking and pack a rucksack for the trip. It would be nice to know how much the rucksack weighs and of course you send the rucksack the message rucksack::weight. The rucksack iterates over its content sending each item the message ::weight. In a single inheritance language, you either have to let all items in the rucksack share a common ancestor which doesn't really make sense or you can define a contract saying that to be allowed into the rucksack an item has to adhere to a specific protocol, e.g. protocol xyz {decimal weight}.


EM

Tuesday, Aug 21, 2007, 1:11 PM





comment on this post

HTML tags will be escaped.

Powered By ASP.NET

Hosted by SecureWebs

Mensa

IEEE