Re: question on anonymous type



Arne Vajhøj <arne@xxxxxxxxxx> wrote:
I'm sure they'll survive - they just may not be as productive.

I doubt it.

It has been discussed as a new feature for Java and it is nowhere
near the top of the popularity list.

That doesn't mean it won't prove to be useful in C#. People often
underestimate how useful a feature will be when they haven't had it.
Look up Blub's Paradox.

The problem with redundancy isn't the possibility for inconsistency -
it's the lack of information density. It takes more space redundantly
specifying information, so there's more to wade through when reading
the code.
The possibility of inconsistency is the classic reason to avoid
redundancy.

In many other scenarios, yes. Not here.

Disk space is cheap.

Who was arguing that disk space was relevant?

You said that it takes more space.

I was talking about *visual* space. *That* is important - disk space
(for source code) generally isn't.

And I find it hard to believe that the usage of var instead of
explicit classname should take longer time to read.

It changes the emphasis of the code. Eric Lippert puts it well:
http://csharpindepth.com/ViewNote.aspx?NoteID=61

I think it is the other way around.

X o = new X();

emphasizes the what and not the how.

First you read that you have an o of type X.

Then you may or may not read where you got it from.

var o = new X();

First you read that you have an o without more info and
then you has to read where it came from to figure out what
it is.

No, you're missing the point - with var, you tend to concentrate on
what you *do* with o rather than the exact type of o (which is part of
the "how").

--
Jon Skeet - <skeet@xxxxxxxxx>
Web site: http://www.pobox.com/~skeet
Blog: http://www.msmvps.com/jon.skeet
C# in Depth: http://csharpindepth.com
.



Relevant Pages

  • Re: I freaking HATE var!!
    ... other 3.0 features than what var uses, ... the syntax that translates queries from the C# 3.0 language and actually ... There are ALWAYS going to be new technologies that are coming out and you, ... 'var' is the necessity of a new feature, my hatred of 'var' is greater ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: I freaking HATE var!!
    ... You can eschew var, as well as extension methods, and the syntax that translates queries from the C# 3.0 language and actually chain the static method calls yourself, passing anonymous delegates and known types as the return. ... There are ALWAYS going to be new technologies that are coming out and you, being a professional in the field, will have to decide on how you want to leverage those technologies in what you do to provide for how you make a living. ... What I'm getting at is, if 'var' is the necessity of a new feature, my hatred of 'var' is greater than that feature. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: I freaking HATE var!!
    ... of other 3.0 features than what var uses, ... the syntax that translates queries from the C# 3.0 language and actually ... There are ALWAYS going to be new technologies that are coming out ... greater than that feature. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Yet Another Newbie Question
    ... client-side script support is not a viable option as that feature can ... Arrays in ECMAScript implementations are of dynamic length by nature. ... var e_cart_descr; ... Even if the declarations above were omitted, that does not make sense as ...
    (comp.lang.javascript)
  • Re: Strong Vs Bold
    ... Said of a program or feature that is considered obsolescent and in the ... STRONG: Indicates stronger emphasis. ... Microsoft MVP - FrontPage ... Those tags are depreciated. ...
    (microsoft.public.frontpage.client)

Loading