Re: 'with' statement
- From: "Peter Duniho" <NpOeStPeAdM@xxxxxxxxxxxxxxxx>
- Date: Tue, 01 May 2007 16:06:59 -0700
On Tue, 01 May 2007 15:30:40 -0700, Jon Skeet [C# MVP] <skeet@xxxxxxxxx> wrote:
Michael A. Covington <look@xxxxxxxxxxxxxxxxxxxxxx> wrote:But there ought to be.
I suspect we'll have to agree to disagree on that front.
And I'll disagree with you both (but agreeably so, I hope). :)
I disagree that "there ought to be" in C#. As the article Mark referred to points out, we lived just fine without a "with" statement in C and C++. It's just not that important a construct to argue that it *ought* to be in the language, even if having it would make life a little easier.
Intellisense in VS makes the usefulness of "with" even less, since it usually only takes a handful of keystrokes to type in the longest of names (exceptions including when you've got a lot of long names that are mostly the same...a bad idea anyway, IMHO :) ).
I do see utility in the "with" statement. I just don't find it so compelling as to demand its inclusion in the language.
I'd rather write a descriptive variable name and put that in front of
each statment than have the ambiguous (when there are multiple levels
of "with") dot on its own.
Ambiguity is, IMHO, a poor argument against a "with" statement. The article Mark referred to brought up the question of ambiguity between a field and a local variable. Well, as VB does, so too could C# just require slightly different syntax for a field than a local (so you can easily tell the difference between ".Text" and "Text"). As far as nested "with" statements go, there are two easy solutions: either disallow nested "with" statements altogether, or only allow access to the inner-most "with" statement in any block of code.
I'd prefer the former, but if the language did the latter but the compiler emitted a warning similar to that used when hiding a local variable, that would be fine with me too.
I don't really see ambiguity as a significant or unresolvable problem, with respect to having a "with" statement.
Pete
.
- Follow-Ups:
- Re: 'with' statement
- From: Andy
- Re: 'with' statement
- From: Michael D. Ober
- Re: 'with' statement
- References:
- Re: 'with' statement
- From: Andy
- Re: 'with' statement
- From: Michael A. Covington
- Re: 'with' statement
- From: Jon Skeet [C# MVP]
- Re: 'with' statement
- Prev by Date: Re: Hashtable ordering
- Next by Date: Re: MsAccess and IA64
- Previous by thread: Re: 'with' statement
- Next by thread: Re: 'with' statement
- Index(es):
Relevant Pages
|