Re: Terminology problem

From: Gary Labowitz (
Date: 06/07/04

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

"David White" <no@email.provided> wrote in message
> "Gary Labowitz" <> wrote in message
> > "Edo" <> wrote in message
> > news:40c3e69b$
> > > Hello
> > > Is ( int &rVal = val; ) a declaration of a reference of type int
> > > the value of val
> > > Or
> > > A declaration of a variable rVal or type reference to int to the
> > > 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
> and die before, the object to which it refers, or it can refer to an
> 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.


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 ...
  • 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. ...
  • 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 ...
  • 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. ...
  • 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". ...