|
|
Choosing A Webhost: |
Re: C# 3.0: msg#00123windows.devel.dotnet.cx
As I noted in my blog entry I'm a bit out of touch on some of the rationale, but I can give some insight (I hope...). All the additions are there to make the Linq stuff work (there may be other 3.0 additions not related as well). Well, the problem with object instead of var is that you end up with a weakly-typed implementation. For example: List products = GetProductList(); object productInfos = from p in products select new {p.ProductName, p.Category, Price = p.UnitPrice}; What can I do with productInfos? I don't have the name of a type to cast it to, so the best I can do is access the values through reflection. With the var syntax, I get something that's strongly typed, and I can get IntelliSense on the instance when I want to access the values. It is possible (or at least it was going to be possible - not sure if it is) to use a real type if you want to pass that type around (ie something like EmployeeContactInfo with just an employee ID, a name, and a phone), but in many cases you don't care about doing that. Extension methods are mostly there to support the query expressions. The "select" part of the query expression is, IIRC, implemented using a query expression. Eric -----Original Message----- From: Discussion relating to the specifics of the C# and Managed C++ languages [mailto:DOTNET-CX@xxxxxxxxxxxxxxxxxxx] On Behalf Of Peter Ritchie Sent: Thursday, September 15, 2005 10:34 AM To: DOTNET-CX@xxxxxxxxxxxxxxxxxxx Subject: Re: [DOTNET-CX] C# 3.0 Eric Gunnerson has some ramblings at http://blogs.msdn.com/ericgu/archive/2005/09/14/466510.aspx, on implicitly types variables and extension methods. I don't buy the justification of these two additions. I don't see the need for implicitly typed variables. The note in the spec. that basically suggests avoiding implicitly typed variables whenever possible says it all. What's wrong with "Object"? I have the same opinion on extensions that require "var": Anonymous Types and Implicitly Types Arrays Extension methods seems to be a hack to recover from lack (or removal, considering C++ roots) of nonmember functions or implicit conversion constructors. It also reaks of a means to circumvent Sealed classes. I started a blog some months ago on extending C# classes without touching the base; but never posted it. You can accomplish what extension methods give you very simply. The additional object initializers seem to be just syntactic sugar to avoid having to write constructors. I don't know what I think about Query Expressions yet. The only compelling additions, in my opinion, seem to be Collection Initializers and Lambda Expressions. Lambda Expressions remind me of Continuation Passing Style. http://www.peterRitchie.com/ On Wed, 14 Sep 2005 15:52:36 -0500, Russell Collins <RCollins@xxxxxxxxxxxxxxxxxxx> wrote: >I couldn't agree more. > >-----Original Message----- >From: Stoyan Damov [mailto:stoyan.damov@xxxxxxxxx] >Sent: Wednesday, September 14, 2005 9:25 AM >To: DOTNET-CX@xxxxxxxxxxxxxxxxxxx >Subject: Re: [DOTNET-CX] C# 3.0 > > On 9/14/05, Eyvind Axelsen <eyvind.axelsen@xxxxxxxxxx> wrote: >> >> Language specification, examples etc can be found here: >> http://msdn.microsoft.com/vcsharp/future/default.aspx >> >> Very cool! >> >> Eyvind. > > I think I'm going to puke: > The implictly typed local variables and arrays extension is letting > lazy bastards write JavaScript in C#. > The object initializers extension is something which I expected in C# 1.0. > The collection intializers extension is useless, and can only serve > book writers write contrived examples. > The anonymous types extension is a replacement of a worst practice, which is returning a quick-and-dirty tupple (tripplet, whatever). We used to return object[] for doing that. > The lamda functions extension is for lazy bastards, which also like to write write-only code. > The query expressions extension is, well, no comment. Really, this is CSql, not C#. > I would really appreciate a slightly more powerful generics to all of the "extensions" above. > Cheers, >Stoyan > P.S. Haven't had much sleep recently > >=================================== >This list is hosted by DevelopMentor(r) http://www.develop.com > >View archives and manage your subscription(s) at http://discuss.develop.com > >=================================== >This list is hosted by DevelopMentor(r) http://www.develop.com > >View archives and manage your subscription(s) at http://discuss.develop.com =================================== This list is hosted by DevelopMentor(r) http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com =================================== This list is hosted by DevelopMentor® http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com
|
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Re: String to Enum, Vince Pacella |
|---|---|
| Next by Date: | Re: C# 3.0, Keith Hill |
| Previous by Thread: | Re: C# 3.0, Keith Hill |
| Next by Thread: | Re: C# 3.0, Keith Hill |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
Free MagazinesCisco NewsReceive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business. subscribe Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field. subscribe The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business. subscribe Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company. subscribe Total Telecom Total Telecom is "The Economist of the communications industry". subscribe |