Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Re: Why does using keyword require a new scope?

Reply
Thread Tools

Re: Why does using keyword require a new scope?

 
 
Herman Eldering
Guest
Posts: n/a
 
      08-23-2003
Hi,

One problem I can think of is this case:

{
using AnyDisposableClass adc1 = new AnyDisposableClass();
using AnyDisposableClass adc2 = new AnyDisposableClass();
}

The sequence can be important, and this is not visible from the code above.
Therefor the current approach is clearer and I think it ways up to the fact
that it needs a little more typing and a couple of indents.

Herman Eldering

"Dave Goldstein" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Why this nuisance:
>
> using(AnyDisposableClass adc = new AnyDisposableClass()) {
> }
>
> when it could have been created this way:
>
> using AnyDisposableClass adc = new AnyDisposableClass();
>
> and then gets disposed when exiting scope?
>
> I believe C# allows anonymous scopes, so the same task could therefore
> have been accomplished this way:
> {
> using AnyDisposableClass adc = new AnyDisposableClass();
> }
>
> Any thoughts/responses? I find the using clause provided to be really
> aesthetically displeasing and clumsy, as the layer of nesting is
> completely unnecessary ecept for the implementation detail of when the
> variable is actually initialized (i.e. scope could exit before the
> variable is assigned; so what! null means do nothing!)
>
> To simplify things, a readonly/const could be implied or required by
> such a use case.
>
> -d
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Why using the new keyword at all for memory allocation? PencoOdStip@gmail.com C++ 6 05-25-2007 01:26 PM
RE: keyword checker - keyword.kwlist Hamilton, William Python 4 05-13-2007 06:31 AM
keyword checker - keyword.kwlist tom@finland.com Python 6 05-10-2007 04:53 PM
findcontrol("PlaceHolderPrice") why why why why why why why why why why why Mr. SweatyFinger ASP .Net 2 12-02-2006 03:46 PM
Re: Why does using keyword require a new scope? Jip from Paris ASP .Net 0 08-25-2003 08:02 AM



Advertisments