Re: Basic question on local variable
- From: Brooks Moses <bmoses-nospam@xxxxxxxxxxxxxxxxxx>
- Date: Sat, 22 Jul 2006 11:05:56 -0700
glen herrmannsfeldt wrote:
Gary Scott wrote:Brooks Moses wrote:Do the compiler-specific extensions to pass by value get around this problem, by allowing the argument to be modified in the function?
Not to my knowledge.
Yes, as far as I know Fortran never adopted that ability, and even if it did guarantee to pass a temporary, as far as I know you are still not allowed to modify it. Fortran compilers are allowed to optimize out the parenthesis in y = addten( (x) ), or even the expression in
y = addten( x+0 )
Right, and I definitely agree that it's not allowed with that syntax. I'm asking about the non-standard %VAL type things, and what they did. Whether modifying the temporary they create (assuming that's how they work) is allowed would be outside the scope of the standard....
Maybe it could be added for 2008.
Actually, it's already been added in F2003 -- see the VALUE keyword that Reinhold Bader mentioned. When a dummy argument is declared with the VALUE attribute, the function acts as if it has received a temporary variable with a copy of the actual argument value (with the usual caveats that the compiler need not be implemented exactly like that), and you are explicitly permitted to modify the dummy-argument variable.
- Brooks
--
The "bmoses-nospam" address is valid; no unmunging needed.
.
- Follow-Ups:
- Re: Basic question on local variable
- From: *** Hendrickson
- Re: Basic question on local variable
- From: glen herrmannsfeldt
- Re: Basic question on local variable
- References:
- Basic question on local variable
- From: Led
- Re: Basic question on local variable
- From: Reinhold Bader
- Re: Basic question on local variable
- From: Gary Scott
- Re: Basic question on local variable
- From: Brooks Moses
- Re: Basic question on local variable
- From: Gary Scott
- Re: Basic question on local variable
- From: glen herrmannsfeldt
- Basic question on local variable
- Prev by Date: Re: Basic question on local variable
- Next by Date: Re: Basic question on local variable
- Previous by thread: Re: Basic question on local variable
- Next by thread: Re: Basic question on local variable
- Index(es):
Loading