Topic: Default Argument Resolving Problem
Author: Boris Rasin <brasin@NetVision.net.il>
Date: 1995/08/14 Raw View
>extern int i = 1;
>extern void f( int x = i );
>extern int main() {
> i = 2;
> f(); // == f(2) of course
> int i = 3; // from now on lokal i hides global i
> f(); // f(2) or f(3) ?
>};
>
>At which point will the *name* of a default argument be resolved?
>- at declaration Point ( so it is bound to a reference )
>or at any individual point f is called ( working like a macro
>and resolving the name whatever it stands for at this moment )?
Default arguments are resolved at the declaration point.
I'm sure I read about it somewhere.
*************************************************************
* Stupid news daemon doesn't want to post an article with
* 'more included text then the new text'.
*
* Stupid news daemon doesn't want to post an article with
* 'more included text then the new text'.
*************************************************************
Author: fjh@munta.cs.mu.OZ.AU (Fergus Henderson)
Date: 1995/08/03 Raw View
Ralf Boecker <boecker@hrz.uni-kassel.de> writes:
>Take a look at this Code:
>
>extern int i = 1;
>extern void f( int x = i );
>extern int main() {
> i = 2;
> f(); // == f(2) of course
> int i = 3; // from now on lokal i hides global i
> f(); // f(2) or f(3) ?
>};
>
>At which point will the *name* of a default argument be resolved?
>- at declaration Point ( so it is bound to a reference )
Yes, at the point of declaration. See DWP _dcl.func.default_ 8.3.6/5.
--
Fergus Henderson | Designing grand concepts is fun;
fjh@cs.mu.oz.au | finding nitty little bugs is just work.
http://www.cs.mu.oz.au/~fjh | -- Brooks, in "The Mythical Man-Month".
PGP key fingerprint: 00 D7 A2 27 65 09 B6 AC 8B 3E 0F 01 E7 5D C4 3F
Author: clamage@Eng.Sun.COM (Steve Clamage)
Date: 1995/07/31 Raw View
In article 14s3@hrz-ws11.hrz.uni-kassel.de, Ralf Boecker <boecker@hrz.uni-kassel.de> writes:
>
>extern int i = 1;
>extern void f( int x = i );
>extern int main() {
> i = 2;
> f(); // == f(2) of course
> int i = 3; // from now on lokal i hides global i
> f(); // f(2) or f(3) ?
>};
>
>At which point will the *name* of a default argument be resolved?
A default parameter value is bound (e.g., names are resolved) at the location
where the value expression appears.
In your example, the default argument value is always the current
value of the extern 'i'.
---
Steve Clamage, stephen.clamage@eng.sun.com
Author: Ralf Boecker <boecker@hrz.uni-kassel.de>
Date: 1995/07/28 Raw View
Take a look at this Code:
extern int i = 1;
extern void f( int x = i );
extern int main() {
i = 2;
f(); // == f(2) of course
int i = 3; // from now on lokal i hides global i
f(); // f(2) or f(3) ?
};
At which point will the *name* of a default argument be resolved?
- at declaration Point ( so it is bound to a reference )
or at any individual point f is called ( working like a macro
and resolving the name whatever it stands for at this moment )?
--
*** Dipl.-Ing. Ralf Boecker Universitaet GH Kassel ***
*** eMail: boecker@hrz.uni-kassel.de FB 16 - Elektrotechnik ***
*** Tel: (+49)561/804-6404 Wilhelmshoeher Allee 73 ***
*** Fax: (+49)561/804-6360 D-34121 Kassel (Germany) ***