Re: Terminology problem

From: Gary Labowitz (glabowitz_at_comcast.net)
Date: 06/07/04


Date: Mon, 7 Jun 2004 09:49:27 -0400


"David White" <no@email.provided> wrote in message
news:3PSwc.6346$%r.89566@nasal.pacific.net.au...
> "Gary Labowitz" <glabowitz@comcast.net> wrote in message
> news:OemdnappJLlvcV7dRVn-uw@comcast.com...
> > "Edo" <edwardoJE@aking.com> wrote in message
> > news:40c3e69b$1@dnews.tpgi.com.au...
> > > Hello
> > > Is ( int &rVal = val; ) a declaration of a reference of type int
to
> > > the value of val
> > > Or
> > > A declaration of a variable rVal or type reference to int to the
value
> > > of val
> >
> > int &rVal = val;
> > decalres a new name for the variable val. It is rVal.
> > You may now use rVal and val interchangeably.
> > rVal is called a reference to val. It exists as long as val exists; that
> is,
> > they share the same scope.
>
> They don't necessarily share the same scope. A reference can be born
after,
> and die before, the object to which it refers, or it can refer to an
object
> that no longer exists. Obviously, you can't allow the latter case to ever
> happen.

Yes, I spoke too quickly there, and misspoke. You are right. Generally,
however, the reference is declared in the scope of the referenced variable
or in a function declaration as a parameter. Same scope in the first case,
different scope in the second. Thanks.

-- 
Gary


Relevant Pages

  • Re: vbs output to txt file
    ... the reference count to that object will be decremented. ... As does going out of scope:) ... You are religiously setting objects to nothing and not ... and so am seriously lacking in both scripting expertise ...
    (microsoft.public.scripting.wsh)
  • Re: Lock-free reference counting
    ... The scope of t is the entire function foo, ... The reference's lifetime is considerably shorter than ... The only way for it to collect it is if no reference is ... Bindings are introduced by various language constructs. ...
    (comp.programming)
  • Re: Lock-free reference counting
    ... scope and value lifetimes are completely separate concepts. ... reference is dropped, then the object could be immediately destroyed ... the mere act of destroying ... so scope-based reference counting keeps values alive a lot longer ...
    (comp.programming)
  • Re: Article of interest: Python pros/cons for the enterprise
    ... create a less flexible Python feature that achieves the ... you can create a temporary object whose reference count will become ... especially in a complex multi-statement scope. ... If you can then request that arbitrary actions be taken automatically when those events happen, you can pair up resource acquisitions and releases very easily. ...
    (comp.lang.python)
  • Re: Scoping in VB.Net
    ... You may be slightly confused about scope, ... As an example of what I mean, think about memory leaks using a language ... variables are not value types (but reference types) and are declared on ... The Windows OS has a reference to it via a "Handle". ...
    (microsoft.public.dotnet.languages.vb)