Language design choices and query comprehensions (by yag)
An interesting part of Project LINQ is the concept of Query Comprehensions. In essence, they allow you to perform a translation from a more declarative syntax to a more object based one. For instance the following internal LINQ syntax in C#:
expr = names.Where(s => s.Length == 5).OrderBy(s => s).Select(s => s.ToUpper()) ;
which is chock full of lambda expressions (Where, OrderBy and Select), becomes legible as:
(C#) expr = from s in names where s.Length == 5 orderby s select s.ToUpper() ;
(VB) expr = select s.ToUpper() from s in names where s.Length = 5
The key here is that behind the scenes the code is the same, but each language can define its own comprehensions to make things easier for their customers. One question this raises is "which is better From...Select as in C#, or Select...From as VB has chosen"? Paul Vick gives both sides of the argument in this blog entry.
Comment Notification
If you would like to receive an email when updates are made to this post, please register here
Subscribe to this post's comments using
Comments
Leave a Comment
About YAG
Yair Alan Griver is the architect for the Microsoft.com community properties. As architect, he is responsible for creating a coherent underlying platform for properties that include blogs.msdn.com, forums.msdn.com, GotDotNet, chats and CodePlex. In addition to MSCOM architect, Alan is also responsible for the continued development of Visual FoxPro. Prior to the architect role, Alan was Group Manager for the Visual Studio Data group. As Group Manager, Alan’s teams produced the tools used inside of Visual Studio .NET, Office and SQL Server that surface data capabilities, as well as Visual FoxPro. Prior to this position, Alan was a Lead Program Manager and Community Evangelist for Visual Basic .NET, driving community interests into Visual Basic .NET. Before joining Microsoft, Alan was Chief Information Officer at GoAmerica, a publicly traded telecommunications (wireless internet) company, and co-founder and CIO of Flash Creative Management a business strategy and technology consulting company.
Alan is the author of five books on Visual FoxPro and Visual Basic, the creator of various development frameworks, and has developed database systems ranging into the thousands of users. He has spoken around the world on databases, object orientation and development team management issues, as well as XML and messaging-based applications.