Highlights from Today's C# Language Enhancements Chat

Highlights from Today's C# Language Enhancements Chat

Q: Does DLinq perform the query on the server-side, or on the client-side?
A: DLinq translates language integrated queries (LINQ) to SQL.

Q: Is C# 3.0 the version shipping with VS 2005?
A: C# 2.0 is the version that will ship with Visual Studio 2005. C# 3.0 is a future version with no specific delivery date/vehicle.

Q: And will the new 'variables' system in C# 3.0 be a mandatory change? Will we still be able to code in a type-safe environment?
A: If you are referring to the "var" feature, it is for type inference. The code will be just as type safe as with inferred typing as the explicit type. You can always specify the type explicitly as before. It is not a "variant" or "dynamic type" or anything of that sort. It is statically typed - just inferred.

Q: I was wondering if you could comment on the dangers of type inference with regards to code readability. I know that in C# especially, code readability was considered to be very important, and that type inference seems to make it more difficult.
A: Certainly every development teams needs to take code readability into account before using features like type inference. Type inference is best used when it make a solution possible or the code easier to understand.

Q: Will DLinq be supported by other vendors (oracle)? Or is this a SQL server only technology
A: The technology is intended to work across multiple databases. We are looking forward to working with ISVs including database vendors like Oracle for broader support.

Q: I would like to see some detailed, non-trivial examples of Expression Trees. Would you mind directing me to some?
A: There is a non-trivial sample on the LINQ Preview called LogicProgramming. It shows you how to get an Expression tree from a Lambda and manipulate that expression tree to do something useful.

Q: Will the Visual Studio IDE incorporate this and allow type-refernece with intellisense/etc?
A: Yes. We will do work in the C# IDE to make sure all of the new language constructs are understodd deeply by intellisense and othe IDE features. Feel free to send suggestions for what you'd like to see in the IDE for C#3.0 to lukeh@microsoft.com.

Q: Can you please post the URLs to the specs so people can read them?
A: For language specs and other information about C# 3.0, please see: http://msdn.microsoft.com/vcsharp/future/

Q: The Linq preview/C#3.0 works without an update to the clr, just a new compiler. Will this be released before Orcas? or are we still talking about a Post-Vista release for c# 3.0 (2007?)
A: We honestly don't know when LINQ will ship as we're really at the first stage of customer feedback. If you've used the Tech Preview, you'll notice many things are missing, like full compiler support, performance optimization and so forth. We will be releasing another LINQ preview that works with the final release of Visual Studio 2005. More then anything, we want to hear customer feedback on the design and the approach.

Q: Will there be subsequent updates to the LINQ bits that work with the RTM version of .NET 2.0 and Visual Studio 2005?
A: We expect that there will be an RTM version of the LINQ Preview.

Q: I'm interested in DLINQ - in particular whether you see this a complete replacement to OR Mappers or just a quick and dirty query. Is it intended to be useable at the Enterprise level
A: We are starting with simple mapping in DLinq. Depending on the feedback we may add more features based on feedback but we will take a minimalist approach and be careful with additions in V1. Whether it suits specific needs will depend on the situation. It is NOT intended to be a "quick and dirty" thing but nor is it going to have the kitchen sink of mapping.

Q: With LINK, our code will be strongly typed..meaning does IntelliSense check if the data source has certain tables and columns?
A: Yes. C# 3.0 is definitely still strongly typed. To accomplish this, DLinq will create lightweight classes to represent the data in your database. When you do queries against your database, they will return objects of these lightweight class type. This will allow intellisense and other IDE features to behave the same as they have in the past.

Q: spec clearly states implicitly typed local variables. Does that mean that there'll be no support for passing vars around
A: var's are not new data types. They are not variants or types that can be reassigned different values. The keyword 'var' is just a placeholder for the real type. When you use 'var' you are asking the compiler to figure out the type for you from the expression use to initialize it. Parameters to functions are not associated with an initializition expression, so there is no means for the compiler to figure the type out for you.

Q: What's new with concurrency in C# 3.0? I've seen speculation over some mixtures with C?. Any of that speculation true?
A: Concurrency is rapidly becoming a very hot topic, given the fact that soon we all will be running on multi-core boxes. Comega introduced the notion of join patterns to deal with asynchronous concurrency, however, there are many other interesting high-level abstractions for making concurrent programming easier. For example, you should have a look at Software Transactional Memory (Tim Harris and Simon Peyton Jones from MSR Cambridge).

Q: We have linq, dlinq, tsql, clr in sql...lots of ways of doing the same thing...is there a best pattern whitepaper on what to use where?
A: Good question, right now there isn't a best practices team, but we are already working with the Patterns and Practices team on providing guidance based on real-world customer usage, through our Technology Adoption Program (TAP) program.

Q: Any plans to expose code model (AST?) for analisys/manipulation?
A: C# 3.0 Lambda expressions allow you to get at the AST for the expressions.

Q: Is var really type-safe? I can write code that uses methods from a String type; but, if something other than a string type is assigned to my var it (I'm assuming) will generate an exception.
A: Yes, var is type safe. When you define a variable, the initializer will allow us to infer the type. Then onwards it will behave exactly as if you had specified the type. e.g. var x = "Foo"; // string inferred

Q: While I can see the underlying purpose of implicit variables and extension methods, the net effect is to make code more difficult to read. Your're lessening the importance of types and constructors which are familiar language constructs.
A: First of all note that type inference does not imply that you loose strong static typing. For example, if you define var x = "Hello World"; the inferred type of x is string, and you cannot subsequently call x.Age for example.

Q: What are the performance implications of using the LINQ style syntax as opposed to standard methods (IE, foreach over string arrays returned by SELECT blah blah seem to not be optimized as normal, and use the enumerator pattern.)
A: The LINQ syntax compiles down to code that implements the enumerator patterns (as opposed to 'foreach' that consumes it). There will certainly be some small cost over just using a loop, since you'll be making calls to MoveNext() and Current as you iterate. We've looked a bit into optimizations strategies such as combining operators and unrolling them to inline code. None of that's in the preview bits.

Q: if DLinq translates language integrated queries (LINQ) to SQL, how connection string and other stuff are specified?
A: DLinq includes a command line tool called SQLMetal.exe that runs against a specific database and auto-generates classes. One of the classes it generates represents the database itself and it inherits from the DataContext class. The DataContext class is the class that has the connection string,

Northwind db = new Northwind("Data Source=(local);Initial Catalog=Northwind;Integrated Security=True";
Table allCustomers = db.GetTable();

var result =
from c in allCustomers
where c.ContactTitle.Length == 5
select c.ContactName;

Q: I am assuming that string s = "a" is faster than var s = "a"; are you guys using reflection to infer the type?
A: They are equally fast. The 'var' is resolved to the true type (string) at compile time.

Q: What was the reason behind var a = 10; C# is a strongly typed language...why not make the developer explicitly state what they are initializing?
A: First, its important to note that this is still strongly typed. The compiler figures out what the type is, and will not allow you to later do "a = 'c'", since this would not be type safe. Second, in this case, there isn't really any benefit to using var, so you may as well just type int. However, there are two cases where "var" is very useful. The first is with complicated generic types. For instance, the following is very verbose: "Dictionary<Customer,List<Pair<string,Order>>> d = new Dictionary<Customer,List<Pair<string,Order>>>." Here you don't lose any readability by changing to var, and you probably gain some readability by being more terse. The second place var is useful is with anonymous types. Since you can't name these types, you need to use var when you want to assign values of these anonymous types to local variables.

Q: Why replace standards such as SQL and XPath with a similar but proprietary query language?
A: We are not replacing any standards. The specific query standards like SQL and XPath are designed as separate query languages and will continue to be available for our users in our products. They were specifically not designed to handle language integration and hence often not suitable for that purpose. Each of them targets a specific domain and does not serve a unified view of data. For these two reasons, we needed to create LINQ.

Q: It's not clear to me, if I build a select statement querying the database in C#3.0 with lambda function inside the where condition, the where condition narrowing is sql server side or client side?
A: The where condition executes on the server. The lambda expression can be realized by the compiler as either IL (code) or Expression tress (data). The query expressions translate into explicit calls against your collection object. The DLINQ API has a collection object that implements these 'query operators' as methods that collect expression trees instead of IL. Later, when you ask for the results of the query, DLINQ turns the expression trees into SQL queries.

Q: What would be the recommended way (API?) for building LINQ expressions programmaticaly? Will there be something like LINQ AST exposed?
A: The Espresso sample on the LINQ Preview shows you how to do this.

Q: Linq, looks to be heavliy based off the reflection, are there going to be any preformance issues with it?
A: LINQ is not based on reflection. DLINQ however uses reflection to create objects out of query results and Expression trees encoded with property/field infos to construct SQL queries.

Danielfe [MSFT] (Expert): To the question on why do we need var, I blogged about this today at: http://blogs.msdn.com/danielfe/archive/2005/09/22/472884.aspx, but in my opinion the best benefit is projection, which lets you project a wholly new type. So I can say select c.Name, c.City, c.Phone which creates an anonymous type that has *inferred* string/city/phone structure and inferred data types.

Q: In your example I could write x.CompareTo(...). If that var is retreived via LINQ, what happens if the database schema changed from string to int? x.CompareTo() is no longer valid.
A: I am assuming your question is about DLinq. A schema change from string to int? would require a mapping change as well. When the new mapping metadata is compiled in, the inferred type would change and hence the set of valid expressions would change as well.

Q: When performing an iteration, i use the following pattern Is this bad? Thanks.
int i = 0;
foreach (obj a in b) {
i++;
}
A: This can be a good idea in some cases, though it depends on the type of "b". If it is a type that has an efficient indexer, you are probably better using a for loop that then uses the indexer to grab the elements, since your loop is tied to the index variable. It's really a matter of style, readability and the efficiency of the various methods/properties on the underlying type of "b".

Q: Are you planning to make any release of LINQ so languages other than C# and VB could take it in account?
A: The beauty of LINQ is that it is truly a multi-language thing. Any .NET language can already hook into the framework today by just calling into the LINQ API's.

Query expressions, extensions methods, and the conversion of lambdas to expression trees are syntactic sugar on top of these APIs.

For example, the F# folks are seriously thinking about adding LINQ support as well.

Q: How does DLinq handle differences between string comparisons, in C# == is case-sensitive but SQL Server behavior can be case/kana/accent-(in)sensitive depending on collation settings?
A: We use the server collation setting. In the end, there will likely be a way to override the default.

Q: With the improvements to C# 3.0, do you plan to bring more intricate relationships between C# and ASP.NET?

A: We are always looking for better integrated experience. We still have some work planned for ASP.NET -LINQ integration but it is too early to be specific. We are actively working on databinding as well as embedded C# 3.0 code in ASP.NET.

Q: Would var work with a class that does not support a default constructor?
A: var works if the declaration has an initializer. The initializer cannot be an object or collection initializer, but it certainly can be any "new" expression.

Q: Will C# 3.0 have extension properties?
A: We are currently looking into extension properties. So stay tuned.

Q: "var" makes the code really strange there should be intellisense which tells what that "var" is
A: We will have IntelliSense support for var, both for determing what the type is and then and being able to type the variable "dot" and get an completion list. We haven't determined the best way to show the informaiton yet, though the most natural way would probably be to hover over var and have it tell you the type (this will be interesting for anonymous types too...). All of the bits that were released at PDC have only very minimal work done in IntelliSense, mostly to make it possible to write (remove all the red squiggles you would usually get) as opposed to making it easier

Q: The XLINQ impl in C# seems kind of verbose. I recall that COmega made use of a literal style of XML (like VB 9). Why was that not implemented in C# 3.0?
A: Your real issue is that XLINQ does not have an impl. in C#, not that C#'s impl. is verbose. I'm not sure the final word has been spoken on this yet. ;-)

Q: Why can't "Object" be used instead of "var"?
A: "object" can hold references to many separate types at runtime. The type of "var" is determined at compile time and so it has the benefits of strong typing

Q: Anonymous Types are supported with the context of method or where ever they are created on the fly. How do i make use of them out side of my assembly or application? Simply, how to return Anonymous types from a method?
A: Yes, anonymous types can never escape the context of the method they are created in. This is enforced only in that the type cannot be named, so it can't be assigned into any field/property or passed to any method/constructor. Because they can't even escape the implementation of a method body, they cannot be seen by another assembly or application. In short, the answer is that you cannot return an anonymous type from a method. Instead, you should give the type a name and create an instance of this named type to return instead. We expect to provide refactorings to automate this process somewhat.

Q: Its easy to write lot of complicated joins in SQL..writing them in C#..would it not make code difficult to understand and length??
A: We are still considering more explicit joins for LINQ. However, I don't believe that joins in LINQ are any more lengthy than joins in SQL. Do you have a particularly bad example to share with us?

Q: Why does LINQ use "from" first, instead of "select" ?
A: For one thing, this ordering allows for better Intellisense support. If you were typing "select Name, Age, Position from EmployeeDB", for example, we wouldn't be able to provide completion list support for Name, Age, etc. because we wouldn't know where those fields were coming from. By putting the "from" clause first, we can assist you by looking up the possible field names. Just one example.

Q: When will the C# 3.0 implementation actually be available? I don't want to put a whold bunch of attention into something that I'm not going to be able to use anytime soon. (Especially considering that 2.0 isn't formally released yet.)
A: We are actively working on updating the preview but we do not have announceable release dates for C# 3.0. It is the next major release after VS 2005

Q: May we expect a release of Linq that works with RC0 and/or RTM of .NET 2 in the near term?
A: Yes. We are very actively working on it right now and would like to get it out as soon as we can.

Q: if "DLinq translates language integrated queries to SQL", how can it be used on non-SQL sources of data? I've seen examples that use arrays/collections as a datasource. SQL translation seems overkill in this case.
A: DLinq is specifically for databases. There are different API's per domain, so while DLinq is Linq for databases and lives in System.Data.DLinq, you can use the standard query operators to query arrays/collections and those are in the System.Query, namespace. The interesting part will be as more different types of data stores create LINQ-enabled APIs.

Q: BTW, I sense that you are facing significant developer push-back on type inference and a few of the other features you are adding. As someone who would normally prefer to spend my time coding in dynamically typed languages, C# is getting attractive!
A: Thanks -- but note that type inference via the "var" declarator syntax does not make C# a dynamically typed language. At the level of simple stuff like "var foo = new Foo();" vs "Foo foo = new Foo();", the var syntax is simply a "syntactic sugar" that saves you having to type the rather redundant type declaration. But when you add compiler-generated anonymous types to the language suddenly you really need a way to say "I have a strongly-typed variable here but I do not know the name of the type". Consider for example a LINQ query that returns a tuple of (string, integer) -- it would seem strange to force you to declare the tuple type just so that it could have a name in the declaration.

Q: What are the reasons for not implementing Extension Methods using the new Partial Types syntax, and while still restricting member access, discovery, etc...... it seems like the partial type syntax is more intuitive.
A: You can only use partial types to split up the definition of your classes in your project. Partial types cannot span assemblies or be used to add on to types already declared or sealed. Are you are wondering why extension method syntax does not look more like a partial class declaration?

Q: Is intellisense supposed to be working for Linq "commands" - from, where, group, select. Everything works fine for me, but I don't get intellisense. Just curious.
A: The pre-release doesn't have much in the way of IntelliSense support. It will work in the future, but for the moment the work that we've done is simply to stop it from getting in the way (for example, we made it so that it doesn't report parse errors everywhere). So for the moment the answer is no, but in the future the answer will be yes

Q: Are there any plans to extend the C#2 ability to require a class to have a default constructor, to require it to have a constructor with a specified signature?
A: There are no plans, but that sounds like a good idea.

Q: Is there any plans to add a reverse iteration option to the language?
A: I don't think there are currently any plans to do this. IEnumerable is implicitly ordered, so that reverse iteration is in the general case either inefficient or impossible (the enumerable could be infinite). In many cases you can do something like "foreach(var c in foo.Reverse()) {...}". There is also a snippet in 2005 called forr which expands into a reverse interation over a collection.

Q: C# seemed to be created as a language as a step away from legacy support for non-object-oriented code and to improve type safety. How are are 3.0 additions like extension methods and implicitly typed variabes in keeping with this theme?
A: Implicit typing is about type inference, not about relaxing type safety. It is quite different from dynamic typing in some languages.

Again, with extension methods, there is an additional dimension of flexibility - not a legacy feature. These are innovations tried out in some functional programming language and not in legacy languages. So they are very much forward looking and consistent with the spirit of a relatively recent language.

Q: future version of vb (VB9) include XML literals and more sql keywords in LINQ than C# does, can you explain why C# team decide have no XML literals and havejust few core SQL keywords.
A: Designing a language is a delicate process, once you put something into the language, it is in there forever. Hence you have to be extremely careful what to put into the language and what to put into the API.

Most languages I know that have query comprehension expressions all have diffrenet syntax.

For example, in VB we have choosen to stay as close as possible to SQL syntax because many VB programmers already know SQL. In C# the query expressions are more liberal than what SQL allows, for example you can interleave from and where, and select comes at the end; it is more like XQuery's FLWOR expressions. And languages such as Scala, Python and Haskell have their own different syntax.

Q: Does LINQ allow us to paint our arbitrary data-architectures with whatever, metadata or functions that are necessary to support LINQ-style queries..... such as a query to find the all nodes the Nth shortest hop from a specified node in an arbitrary graph..
A: If I understand your question correctly, you want to LINQ-enable your custom data structures and even add methods that are custom to your data structure like FindSmallestNodeHop(). The answer is yes, we are looking to create documentation on how you can implement the LINQ pattern on a different data structures, but the bottom line is that it's fully extensible. If your object implements IEnumerable, you can use the LINQ query commands like select,from, where etc today.

Q: spec clearly states implicitly typed local variables. Does that mean that there'll be no support for passing vars around. If we don't then var will loose usabilityand the power of true type inference is lost once you cannot write var func(var param)
A: You won't be able to write functions using 'var' as parameters or return types. 'var' is not a type, but a place holder that the compiler will fill in based on the initializer. It may be possible to support var as a method return type, since it would be possible to infer the correct return type, however, it would be much more error prone to allow your method declaration to fluctuate because you changed a line of code in its body.

Q: F#? Whazzat?
A: F# is a cool functional language done by Don Syme in MSR Cambridge (http://research.microsoft.com/projects/ilx/fsharp.aspx). From the F# home page: "Combines the strong typing, scripting and productivity of ML with the efficiency, stability, libraries, cross-language working and tools of .NET".

Q: in what situations would var add to readability?
A: Sometimes the type is painfully clear from the right-hand-side of the statement. For instance "var peopleOrders = new Dictionary<Customer,List<Pair<string,Order>>>()" is very likely more readable than naming the type twice. There are some other cases where var does not add to readbility, and in many of these cases, it is prefferable to use the actual name of the type instead of var.

Q: Jomo: would you compare var to const Object (if I could borrow from C++). If so, why not use const Object?
A: Its not the same. 'const object' means the value can't change at runtime. 'var' means the type can't change and this is determined by the compiler.

Q: Is LINQ works only with MS SQL or any SQL or it provides extentions for MSD SQL 2005
A: Current preview is implemented for MS SQL Server 2000a and 2005. We are exploring various options for broader relational database support including working with other vendors.

Q: Are you planning any release for LINQ so any languages could start using it? I mean, for consuming Func objects and so on, because I work in a language that already has some of these features and we would like to integrate it...
A: LINQ standard query operators are just normal methods. Any language that can use generics can call them. As can any language use DLINQ. The languages themselves will have to choose to implement query expressions or comprehensions or other syntax that makes using LINQ simpler.

Q: What plans do you have involving XML Serialization in C# 3.0?
A: XML serialization is a frameworks, not a language related issue. However, in the context of XLinq (the new XML API) we are looking at providing typed access over XML.

Q: I'd like generic constrinaint new(...) with parameters because classes with default constructors are not good. Is it possible to see the feature in future versions od C#?
A: Possible, yes, but unlikely unless CLR is improved to do it as well. There are a variety of interesting constraint changes that the CLR team are looking into. Unfortunately, these kinds of changes will occur in the future (well after C# 3.0)

Q: Why not add the Design Patterns inside the .NET so we can create MVC, MVP, Singleton etc etc
A: This is something the Patterns and Practices team, http://msdn.microsoft.com/practices/, is actually working on where you will be able to download and have templates for specific design patterns in Visual Studio 2005.

Q: will there be strong debugging support for LINQ?
A: Yes, this is something we're thinking a lot about.

Q: I assume there plans to add List to the classes extended by Linq? I seem to recall having to write my own Where() method.
A: The extension methods that are provided by LINQ extend all IEnumerable's which includes List. You'll be able to use the Where extesion method on arrays, Lists, strings and all kinds of other types.

Q: Will DLINQ support INSERT, UPdates and Paging and Stored Procs
A: DLinq does support insert/update/delete through the SubmitChanges() API. We also do have some support for sprocs for query and insert/update/delete that is discussed in the LINQ Preview documentation. We have some paging support through Take/TakeWhile.

That said, we plan to explore DML (insert/udpate/delete command equivalents) and better paging and sproc support. Please send us any specific feedback you have if you find the current support insufficient.

Q: DLinq has been very interesting to play around with. SQL Profiler helps me get my arms around it. But, what I'm not clear on is architecturally what is the best way to implement it. Certainly you wouldn't want to use type-inference to create DAL objects?
A: I think you are reference to anonymous type constructors, not type inference. You are correct, you would not use anonymous types to represent data access layer (DAL) objects. However, you are allowed to use anonymous types to represent read-only projections of your DAL objects.

Q: The XLINQ impl in C# seems kind of verbose. I recall that COmega made use of a literal style of XML (like VB 9). Why was that not implemented in C# 3.0?
A: I am happy that you like XML literals. We have not yet decided if they will appear in C# as well.

Q: Is the listof new features in the 3.0 spec final or any other things being considered. What about functors?
A: We are still open to new things. Do you mean something like standard ML functors? We have functors with lamdba expressions and delegates.

Q: Are there plans to support indexes on in-memory collections?
A: No concrete plans yet but there are discussions for sure.

Again please send us feedback about top priority scenarios / features - especially from active and expert users like yourself.

Q: LINQ looks exactly like SQL, except the Select is at the end. Why not just put the select at the beginning?
A: Paul Vick discussed exactly this question in his blog today. http://www.panopticoncentral.net/archive/2005/09/21/10553.aspx\>

Q: Wouldn't a new keyword for extension classes be wise instead of it just being a "regular" static class? That way the compiler can enforce that all methods in an extension class be extension methods? (i.e. public extensions class MyExtensions { })
A: We thought about that too. Its likely we'll open it up again and reconsider the alternatives. Currently we are having trouble finding a good way to define extension properties.

Q: What are the major differences between the C++ Templates and C# Generics, is it better, same or worst?
A: Unfortunately I have to pick an answer you didn't give - they are different  In fact, they are different enough that managed C++ supports both. Generics are implemented in the runtime, while templates are source expansions (so with Generics you don't have to ship the source to people that want to use your library). Generics start off with the assumption that the only methods that you can call on a type argument are those that are defined on object, and you must explicitly state through constraints additional methods to call; templates, on the other hand, verify that any of the arguments that you've constrainted the templatized type with have the methods that you invoke on them, through expansion, at compile time.

Q: I think Reverse implemented by the language or library could be more efficient than self written wrappers...
A: Maybe. We do actually provide a Reverse extesnion method in the System.Query.dll that is part of LINQ. However, it is not very effiecient, since it is implemented for the general case of IEnumerable. For specific types which support efficient indexers, you could actually implement a more efficient Reverse().

Q: Jono: So var s = "string"; s = "text"; is valid, but var s = "string"; s = 10; isn't?
A: That's right. The second won't compile.

Q: Are there any relations between DSL and new C# features?
A: We think of LINQ as features added to C# to enable mini domain specific languages right in C#.

Q: How about to add a dot-like operator (or dot for Nullable) which gives null for x.a.b.c if any of x, a, b, c is null. I think it is useful/important for 2.0 and especially for 3.0.
A: That one is currently on our design-team short list.

Q: DLINQ seems to be implementing change tracking, but the fields in the database-mapped classes are actually members, not properties. Does this mean that C# intercepts member write access, or does it compare the actual to the original values before writing?
A: First thing - you can use either fields or properties to map.

Second thing, we support both comparison based as well as notification (rather than interception) based change tracking. If you use our code gen (SqlMetal.exe) or implement a similar notification pattern, you can get the optimization benefits of copy on write. Otherwise, DLinq defaults to conventional original vs current value comparison.

Q: There's "virtual visual studio" sessions that let people evaluate Visual Studio. Will there be something like this for C# 3.0?
A: The short answer is "not yet". We'll have virtual machines where you can play with C# 3.0 as it gets closer to shipping, but it is still in a tech preview state. Many customers have asked for more Visual Studio 2005 virtual sessions and we are in the process of adding those.

Q: Where we can download the C# 3.0 stuff most likely its Framework 3.0 and when
A: You can download the LINQ preview code from here, today.
http://msdn.microsoft.com/netframework/future/linq/

The plan right now is to make C# 3.0 LINQ features work without any changes to the 2.0 runtime. We do not anticipate needing to add new instructions to IL, etc, to make this work.

Q: Are there plans for/is there already a way to allow developers to create and add their own domain-specific language (like LINQ) to the C# compiler/IDE?
A: Yes, the C# 3.0 language allow you to create DSLs within C#. See the LogicProgramming sample in the download for an example of this.

Q: It has so far been unclear to me how Extension methods will interact with access specifiers - i.e. can my extension method access private data?
A: No. Extension methods only appear to the caller as instance methods. They are still static methods an cannot access private members of the class they pretend to be declared on.

Q: Will C# 3.0 be made to work with Visual Studio 2005 eventually, or will we have to wait until a new Visual Studio?
A: The current preview works with VS 2005 beta2 and we are working on an updated preview for VS 2005 release version. Final C# 3.0 will utilize new and cool improvements like IDE support in the next release of VS (after VS 2005). C# 3.0 will be a part of the next VS release, not VS 2005.

Q: What are the recommendations to use the "var", cause we can use it almost everywhere (Except for Parameters and Return types as mentioned)
A: You should use "var" when you have to (i.e. when you are using anonymous types) and when the type is clear from the context (i.e. "var x = new List()". In other cases, you should strongly consider not using var for readability. More guidance on this will be provided in the .NET Design Guidelines and elsewhere before C# 3.0 ships.

Q: can LINQ be used with WMI?
A: They should be able to work, assuming WMI classes inherit from IEnumerable. If it doesn't work out of the box today, certainly it is one area that we can enable LINQ support for in the future.

Q: could you please explain more about the "this" keyword used when defining and extension method? why is it needed?
A: The 'this' keyword is what signals to the compiler that the method is an extension method. Without it, the compiler would think the method was a standard static method.

Q: The LINQ Project whitepaper is real light on XLinq details. Is there a similiar expression tree evaluation in XLinq that delegates/maps to XQuery?
A: XLINQ has its own white paper that you can find on MSDN. XLinq is an in memory API like the XML DOM. So far, the standard query operators using IEnumerable have been sufficient for XLinq. We have not planned on extending XLinq to capture expression trees. It is unlikely that performance will be improved this way for XML documents. Now, an XML database on the other hand might. :-)

Q: WRT extension methods, my understanding is that you run into method ambiguity problems if you use the same method (select) on both DLinq and XLing in the same file. Will there be a way to get around this ambiguity?
A: No, this should not be a problem. The Select method used for DLinq actually has a different signature which is used to support Expression Trees. There should not be any ambiguities when using DLinq and XLinq together.

Q: To ErikMeijer. "in the context of XLinq (the new XML API) we are looking at providing typed access over XML". Could you please give some more detail or an example of that? Thanks.
A: Assume that you have an a variable P whose value is the XELement John Doe42. Now instead writing

XElement P = ...create an untyped representation of Person ...;
int age = (int)P.Element("Age");

you would like to write

Person P = ...create a typed representation of Person ...;
int age = P.Age;

with no cast and no strings. We are looking at how we can provide you with a strongly typed experience on top of XLinq, possibly, but not exclusively, starting from an existing XSD.

Q: Will the LINQ bits that ship with the VS 2005 RTM be limited to 32 bit Windows as is the case with the PDC bits or will we have the freedom to compile to Windows 64 bit?
A: To be clear, you can compile managed code and target 64-bit support with Visual Studio 2005. You can then xcopy your exe to a 64-bit server or a 32-bit server without needing to recompile for a specific processor. What won't work is running Visual Studio 2005 the *tool* on certain versions of 64-bit.

Q: Will DLINQ have the ability to materialize collections that derive from EntitySet?
A: The current preview doesn't support that but we will look into it.

Q: If I am enumerating through a collection, what is the recommeded way for removing an item from the collection.. the way I have been doing it is enumerate the collection in reverse and remove the item...
A: Some collections/enumerators are robust in the face of having items removed during enumeration and some are not. Here are a few ideas if you find yourself having to remove items from a collection where the enumerator and collection do not keep each other apprised of changes to the collection:

  1. As you've discovered, going backwards sometimes can help, because after all, you're then shortening the portion of the dataset you've already seen, not the stuff left to go. This trick is not guaranteed to work on all collections though.

  2. Enumerate the collection and create a new collection of "items to delete later". When you're done enumerating the collection, enumerate the "items to delete later" collection and delete all of them. That way you are not enumerating the collection that you're deleting from. If you're deleting a small number of items, this can work quite well.

Q: What kind of changes if any would we have to make on our datatypes to make them compatible with LINQ?
A: All data type are compatible with LINQ. DLINQ, on the other hand, only supports translation of certain types to the database. If you mean, what would you have to change to make your collection types LINQ compatible, then merely implementing IEnumerable would be enough.  The standard query operators in LINQ work with IEnumerable. So right now at least, you don't need anything special beyond that.

Q: I see that VB9 is offering Dynamic Interfaces... will C# 3.0? How about any other features that allow C# to act like a duck-typed language?
A: Dynamic interfaces in Visual Basic are a way to provide a statically typed view over a late-bound call. Without late binding, dynamic interfaces by themselves do not add much value.

Q: Since LINQ runs on 2.0, are other languages/compilers (IronPython, Monad, Mono CSC, etc) free to implement LINQ prior to .NET 3.0?
A: Yes, I've seen blog entries about very-early support for LINQ in both Monad and Mono.

Q: Implicitly typed variables sound really dangerous outside of LINQ, could a programmer completely avoid "var" when using LINQ?
A: Yes, it's possible to avoid var (though it often is extremely useful) by always defining the structure of your data as a new type. This can make projection more tedious since you'll need to define a named type for the result instead of using an anonymous type.

Q: Is the alternate sql syntax available for extension methods written by us? How is the alternate syntax (select, where from) mapped onto my extension methods? Is this just through the name and type?
A: Extension methods are static methods that appear like instance methods on other types. The SQL like syntax of LINQ (query expression) is translated by the compiler into a series of method calls on your collection class. You can use either normal methods on your collection type or extension methods to implement the methods underlying the query expressiontha the SQL like syntax is translated into.

You can add your own extension methods and take advantage of the translation from the query expression syntax (from ... where ... select ... etc.). But the query expression syntax is language-defined.

Q: Re LogicProgramming: Could this example be pulled out and annotated to explain how and why it works?
A: I tried to put explanatory comments in the sample when I wrote it. I realize its a complex topic and sample. Maybe we could strike up a conversation outside of this chat and hopefully I could answer your questions in detail. Best way to contact me is through my blog (http://blogs.msdn.com/jomo%5Ffisher/) from there I'll get you my email and we can go from there.

Q: Are there any examples of using the new select syntax over XML?
A: Most definitevly! If you go to the LINQ website, you will find many examples. The XLinq API was designed explicitly with this goal in mind. For example, the XLinq overview document at http://msdn.microsoft.com/VBasic/Future/_Toc112834469 gives the following example:

new XElement("contacts",
from c in contacts.Elements("contact"
select new object[] {
new XComment("contact",
new XElement("name", (string)c.Element("name"),
c.Elements("phone",
new XElement("address", c.Element("address")
}
);

Q: I have also heard rumors of multiple return methods ( i.e. public int int MethodName(){ return a,b; } ) in C# 3.0I do not believe these are true, but is it a possibility?
A: You can't do exactly what you are describing there, but you can accomplish essentially the same thing using "yield return". For instance, "IEnumerable MethodName() { yield return 1; yield return 2; }" and then "foreach(int i in MethodName()) { Console.WriteLine(i); }". This allows a method to return a stream of values that are returned "one-at-a-time." so that processing of the first return value happens immediately after it is returned and the second isnt' returned till it is asked for.

Q: It is possible to use SQL Server stored procedures with DLINQ? Can anyone elaborate on "DLINQ and stored procedures" topic?
A: Yes. Please see the DLinq Overview Doc (in the LINQ preview) for examples of sproc usage.

Q: Is there something new to support ASPECT coding ( some kind new Attribute types)?
A: We are open-minded about AOP, in fact Anders and I will attend a workshop on aspects organized by Ralf Laemmel on campus soon. Personally, I feel that AOP is still too young a discpline to be incorporated into a mainstream language; judging from the big stream of conference papers on the topic, it is still too much an open research problem.

Q: Do you plan any way of retro-fitting an interface to a class? e.g. If a library class declares a method Print, and I have an interface IPrintable, I would like to be able to note that the lib class implements the interface so that I can use it in a collec
A: No, we don't have a way of doing this directly in the language. However, you can always create a lightweight wrapper which implements the interface and forwards all calls to an object of the type which has the Print method.

Q: You mentioned databinding enhancements. Would that include generic data controls (eg, GridView?
A: Great question. Unfortunately, we are still in the early stages here for me to be concrete. We will look at both WinForms/WPF(Avalon) and ASP.NET binding support for sure but the details are not yet determined.

Q: What I meant by "natural language" is the ability to do "from c in foo.GetThings() where c.State = "NY", select c.State" as opposed to having to revert to method call/lambda syntax "foo.GetThings().Where(c => c.State = "NY".Select(c => c.State)"
A: Currently the plan is to only have the 'natural language' syntax for a certain set of keywords. In order to call other extension methods you would have to use the method call syntax...

Q: "Designing a language is a delicate process, once you put something into the language, it is in there forever". Excellent comment. If D/LINQ falls by the way-side, do the other proposed C# 3.0 additions become hard to justify or moot?
A: An interesting thing is, i don't think you'll see query leaving the language space again. The LINQ additions make sense because they are general and substantiate the query paradigm. Libraries like DLINQ may come and go, however.

Q: A compiler option to accept only C# 1.x, or C# 2.x, or C# 3.x would be nice.
A: The 2.0 compiler has a switch that tells it to conform to the ISO-1 standard, which maps fairly closely to C# 1.0. We'll look at that switch again to see whether it makes sense to extend it for C#3.0.

Q: should functional languages such as F# change implementation to use LINQ? E.g., interoperation between F# and Nemerle is horrible, even though both use the same constructs. Is there any idea to create a unified basis, or any place to post/send ideas?
A: Now that the family of delegate types Func, Func<S,T>, ... is part of the framework, and used throughout the LINQ APIs, I would think it makes sense for languages to represent HO functions using this type.

Q: Is there any intellisense or tool available to write the Lambda Expressions?
A: In the prototype bits distributed on the web and at PDC there is very little IDE support for lambda expressions. By the time C#3.0 is released though, we certainly intend to do a lot of work to make sure that the IDE fully understands lambdas and helps you out with typing them. We have a bunch of ideas for this, but we're always interested in hearing any ideas you have as well.
Q: Matt - My extension methods could include Select( this ...) would using the new Select sntax (not the .Select direct extension call) call my Select extension method?
A: Yes, your method would get called in both cases.

Q: Is there any intention of ever allowing multiple inheritance in C#? Sometimes this would be really handy.
A: No. Many cases can be handled using existing constructs like interfaces. And adding multiple inheritance creates a whole set of problems.

Q: Where I can get all the chat back? Sessinon timeout throw me out
A: Transcript will be posted in the Transcript Archive (http://msdn.microsoft.com/chats/transcripts/default.aspx) in the next 5-10 business days.

Q: I don't think requiring that a class have a specific c'tor if the class has no data members is wise.
A: I understand, however, I doubt we'll introduce new syntax or break existing behavior to enable that.

Q: How will the rollout of LINQ affect relate to datasets and/or typed datasets?
A: hopefully, LINQ will enhance use of datasets and typed datasets. DLINQ may be thought of as an alternative of using datasets, but LINQ itself is goodness for everyone.

Q: Is any good way to do deep copy? If we have large objects its really hard to implement the ICloneable, is there any pattern or way to accomplish it (Other then Serialization Way)
A: The only general way to do this for an arbitrary type is through reflection. However, there are patterns for implementing this on a particular class. Take a look at the .NET Design Guidelines document for information about this.

Q: Any thought about using external xml files to specify database mapping instead of attributes. This would make it easier to change database schemas or database vendors.
A: There is tradeoff involved in using attributes vs external mapping file. We have received feedback from both sides and are reviewing it. I have discussed some of the tradeoffs on my blog at http://blogs.msdn.com/Dinesh.Kulkarni/. Keep the feedback coming. We are still in relatively early stage of design so we can best utilize the feedback we get.

Q: Is there a chance to add aspects to C#, perhaps the CLR in a better way than context binding?
A: As I mentioned in an earlier answer, my feeling is that it is too early for AOP to be integrated into the mainstream. It is still to "vibrant" of a research area.