logo       

Choosing A Webhost:
A web hosting service is a type of Internet hosting service that allows individuals and organizations to provide their own website accessible via the World Wide Web. Web hosts are companies that provide space on a server they own for use by their clients as well as providing Internet connectivity, typically in a data center. Web hosts can also provide data center space and connectivity to the Internet for servers they do not own to be located in their data center, called colocation. more...

Re: C# 3.0: msg#00126

windows.devel.dotnet.cx

Subject: Re: C# 3.0

I'll see if I can do a bit better.

The way that the query below works is that the compiler writes a type
like:

public class ProductsGenerated0x333
{
public string ProductName;
public string Category; // might be an enum, or
something else...
public Decimal Price;
}

And what you get as the result of the query expression is:

Sequence<ProductsGenerated0x333>

Where sequence<T> is somewhat like IEnumerable<T> (I forget the
differences).

So you can easily write something like:

foreach (var info in productInfos)
{
Console.WriteLine(info.ProductName, info.Category,
info.UnitPrice);
}

Hope that's a bit easier to understand.

On the database side, that presumes some sort of mapping behind the
scenes - the compiler has to have a way of knowing that there's a table
named products and a column named Category, and if those things change,
then the mapping has to be updated, and at that point you would get a
compilation error.

OT: At one time there was access to some terminal server machines that
you could remote desktop into. Not sure if they are still around...

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: Friday, September 16, 2005 11:19 AM
To: DOTNET-CX@xxxxxxxxxxxxxxxxxxx
Subject: Re: [DOTNET-CX] C# 3.0

Thanks for responding, I know you're not "the C# 3.0 guy"--you just have
a blog entry on it :-).

I must be missing something. I understand that, from the compiler/CLR
point of view, var is strongly-typed. But, from a
compile-time/programmer point of view it is not.

if I write:
var productInfos =
from p in products
select new {p.ProductName, p.Category, Price = p.UnitPrice};

What methods could I possibly use on collection entries in productInfos
that is guaranteed to be available, other then Object members--like
ToString(). Can I even use other-than-Object members at compile time?
If I can, and I expect Category to be a String type will this work:
foreach(var p in productInfos)
{
Debug.WriteLine(p.Category.Length); // String.Length }

If that's valid; what happens if I change the database schema and
Category is now an int? Do I get a run-time exception?

OT: Was I dreaming, or is there some on-line tool at microsoft.com
equivalent to a virtual Visual Studio session?

http://www.peterRitchie.com/

On Fri, 16 Sep 2005 10:38:57 -0700, Eric Gunnerson
<Eric.Gunnerson@xxxxxxxxxxxxx> wrote:

>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® http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com



<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

Recently Viewed:
qnx.openqnx.dev...    gcc.libstdc++.c...    solaris.opensol...    information-ret...    misc.misterhous...    web.catalyst.ge...    apache.webservi...    redhat.release....    hardware.lirc/2...    kernel.autofs/2...    technology.sust...    linux.vdr/2003-...    editors.lyx.gen...    org.user-groups...    netbsd.devel.pk...    xdg.devel/2004-...    version-control...    jakarta.slide.d...    debian.packages...    creativecommons...    ports.ppc.embed...    bug-tracking.bu...   
Home | blog view | USPTO Patent Archive | advertise | OSDir is an inevitable website. super tiny logo

Free Magazines

Cisco News
Receive 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

Navigation