Re: Local variables - quick question

From: Stefan Turalski \(stic\) (stefan.turalski_at_kruk-inkaso.com.pl)
Date: 02/27/04


Date: Fri, 27 Feb 2004 07:31:36 +0100

Uzytkownik "Jon Skeet [C# MVP]" <skeet@pobox.com> napisal w wiadomosci
news:MPG.1aa7f63d48871bb098a266@msnews.microsoft.com...
> Stefan Turalski (stic) <stefan.turalski@kruk-inkaso.com.pl> wrote:
> > Thanks for your quick answer - all what I did was to rename this
variable.
> > btw. Is there a way to read ahead variable scope?
> What exactly do you mean by "read ahead variable scope"?

What should I do if I want to examine one of my variables if it is in its
scope or no ?
Debbuger could do it in some why ?

Variables declared localy as far as I know should be destroyed by GC after
their scope ends.. I'm I right ? (rather not, but I have no idea what the
answer is)

> > Or where msdn gives info
> > about scope of variables - I wasn't expecting that local for() - loop
have
> > scope over this loop scope ;-)
> Look at section 10.7 of the ECMA C# spec
> (http://www.jaggersoft.com/csharp_standard/10.7.htm)

- great link! thanks a lot

> or section 3.7 of the MS spec
> http://msdn.microsoft.com/library/default.asp?url=/library/en-
> us/csspec/html/vclrfcsharpspec_3_7.asp,
> aka http://tinyurl.com/394xc

- another good link (this one I have reed before writing on group - and then
I was wondering what:
"Scopes can be nested, and an inner scope may redeclare the meaning of a
name from an outer scope."
mean ? I asume that when I write another for() loop with the same int i
iterator I only redeclare it ?

What is the dipper (memory?) backgroud of this 'redeclare' ?

Sorry for all this questions but I need to know !!!

And once again, thanks for your help...

--
best regards
Stic


Relevant Pages

  • Re: Local variables - quick question
    ... You can't use a variable which isn't in scope within ... being alive by the garbage collector. ... > iterator I only redeclare it? ... that within a nested block it is not possible to declare a local ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Scope of compiler directives?
    ... The MemChk procedure in the code ... > body is not called unless I redeclare the DEVELOPMENT bit after the Begin. ... The scope is always local to the file. ... Only directives set on the commandline of the compiler (aka set in the ...
    (alt.comp.lang.borland-delphi)
  • Re: About String
    ... My idea is that every statement list is a scope. ... You declare something inside a loop body, ... The same sense as declare blocks. ... SCOPE [DECLS] STATEMENTS END-SCOPE ...
    (comp.lang.ada)
  • Re: Which scope for variables being used in a loop?
    ... can't be GC'd until the scope they are declared in exist. ... inside of the loop. ... overlay local allocations in another loop. ... declaration itself, such that the pointer-value of the variable is ...
    (comp.lang.java.programmer)
  • Re: Scope Best Practice
    ... creating a new object versus the cost of maintaining it in memory?" ... the object is ready for GC once the loop is complete ( ... even if it remains in scope because it is not being referenced anywhere ...
    (microsoft.public.dotnet.languages.csharp)