From 3485957819662822853
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,fb1a92fa405c930c
X-Google-Attributes: gidf78e5,public
From: clamage@eng.sun.com (Steve Clamage)
Subject: Re: nested functions
Date: 1999/06/17
Message-ID: <7k9b98$4jo$1@engnews1.eng.sun.com>#1/1
X-Deja-AN: 490730587
Approved: Valentin Bonnard <bonnard@clipper.ens.fr>
References: <7jd4c5$nup$1@nnrp1.deja.com> <_xh83.25803$wk2.383242@newscene.newscene.com> <082d72743190c69CPIMSSMTPU07@email.msn.com> <7jvh45$5ms$1@engnews1.eng.sun.com> <7k617d$pt8@abyss.West.Sun.COM>
X-Original-Date: 16 Jun 1999 23:16:56 GMT
Organization: Sun Microsystems Inc., Mountain View, CA
X-Auth: PGPMoose V1.1 PGP comp.std.c++ iQBVAwUAN2koOawEuYhIxRhxAQGKKgIAkYN2022ZdvurpG3PDoagBjEqXj4M6281 Z0ZuOh/2RJIzM9mt5LVQ8+iXSXrWnRM3X1Ds2u8vb8E8l02r17FRwQ== =izRT
Newsgroups: comp.std.c++

stanley@West.Sun.COM (Stanley Friesen [Contractor]) writes:

>In article <7jvh45$5ms$1@engnews1.eng.sun.com>,
>Steve Clamage <clamage@eng.sun.com> wrote:
>>"G.B." <gb@web1.ucar.edu> writes:
>>
>>>John Potter <jpotter@falcon.lhup.edu> wrote in message
>>
>>>You can have a var of that type anywhere. I only meant it is useless outside
>>>of the scope of parent function.
>>
>>Huh? You can do it in Pascal, for example.
>>
>>But using it outside the scope of the parent function would
>>be the only point of having local funcitons in C++, it seems
>>to me.

>I think you and John are meaning different things by "outside the
>scope of the parent function".  He took it to mean "the scope of the
>parent function has ended due to the function returning".  In that case
>what he said is *indeed* correct.   And you cannot call nested functions
>like that in Pascal either - the parent function has to be at least *active*.

It doesn't help the discussion to confound the terms "scope"
and "lifetime". They are different concepts.

"Scope" is a static property of the source code. A scope begins
with the declaration of a name and ends with the block in which
it is declared.

"Lifetime" is a dynamic property of the executing code. Lifetime 
begins when the flow of control passes through a definition, which
might be never. Lifetime ends according to the flow of control and
the category of the thing: static object, auto object, function.
For a namespace-scope object, or an auto object in a function that
calls no other functions, the scope and lifetime coincide, if
space and time can be said to coincide.  Otherwise, scope and
lifefime are different.

I know that John would not ordinarily confuse these concepts,
although it would appear that some others participating in the
thread have done so.  I assumed John meant what he said.

--
Steve Clamage, stephen.clamage@sun.com
---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]



