• Feeds

    Subscribe in a reader

  • Ads

Inspired by Nikhil's wish list

Nikhil posted his wish list for browsers and scripting.

One thing that I wish for in the CLR world is native support for the "objects as associative arrays" concept that's fundamental to many dynamically typed scripting languages. Being able to access an object's state via either foo.bar or foo["bar"] is tremendously powerful.

It irritates me that converting a structured CLR type into IDictionary<string, object>/IList<object> requires a deep object copy and is thus a linear operation with respect to the number of nodes in the object graph. It would be so nice to be able to convert freely between a statically typed representation and a structurally typed representation in sublinear time.

Viva la expando! (in spirit, but almost certainly not in practice)

Update: fixed typo

#1 Erwyn van der Meer on 5.20.2006 at 6:46 AM

I like it that VB9 is going a lot into this direction with the concept of dynamic interfaces and identifiers. It is all using reflection under the covers, but it saves tons of code for some dynamic scenarios (http://www.idealliance.org/proceedings/xml05/ship/247/VisualBasic9.HTML#d0e1273). The new syntax opens the way for a better implementation behind the cover in future versions of the CLR. However, VB9 isn't going to support the expando notion in any form.Of course, we could use JScript.NET which has native support for "objects as associative arrays" from CLR 1.0 on. Too bad tool support from Microsoft is non-existing for JScript.NET. So it was kind of dead on arrival.WPF has taken a completely different approach to expando properties called attached properties (http://www.longhornblogs.com/rrelyea/archive/2006/02/09/WpfAttachedProperties.aspx). It would have been great to see native language support for this notion in C# 3.0 and VB 9.0 and possibly a native implementation in a new CLR.