call by address (was Re: compilers and linkers) 
Author Message
 call by address (was Re: compilers and linkers)


Quote:
>    DO 10 I = 1, 2
>10  WRITE (*,*) FUNC(3)
>    END
>    LOGICAL FUNCTION FUNC(K)
>    INTEGER K
>    IF (K .EQ. 3) THEN
>            K = 5
>            FUNC = .TRUE.
>    ELSE
>            FUNC = .FALSE.
>    ENDIF
>If all parameters are truly passed by address, then the constant "3"
>would be changed for I.EQ.1 and therefore the second invocation of
>FUNC would return .FALSE.  

It doesn't have to do that.  It depends on what the "address" of a
constant is.  Except for some early, buggy ones, most call-by-address
implementations treat a literal parameter as an expression: the value
is pushed on the stack, and the address of the stack temporary is
passed to the subroutine.  If the parameter is assigned to, it is this
stack temporary that is changed, not the original in the literal pool.
But it is still the case that the parameter is being passed by address.

Quote:
>This somehow no longer seems like a comp.lang.c issue..

I agree.  I've directed followups to comp.lang.misc.

---
Barry Margolin
Thinking Machines Corp.


seismo!think!barmar



Mon, 19 Apr 1993 14:25:00 GMT  
 call by address (was Re: compilers and linkers)
| >If all parameters are truly passed by address, then the constant "3"
| >would be changed for I.EQ.1 and therefore the second invocation of
| >FUNC would return .FALSE.  
|
| It doesn't have to do that.  It depends on what the "address" of a
| constant is.  Except for some early, buggy ones, most call-by-address
| implementations treat a literal parameter as an expression: [...]

The fortran II language consistently treated constant arguments by
passing the address of the original constant.  Since all occurrances
of one constant value were treated the same, it made for some hard to
find bugs.  The language manual pointed out that using constants for
arguments that were assigned to was invalid.  They wised up when they
wrote Fortran IV.

Dale
--

UUCP: ...!seismo!harvard!mit-eddie!culdev1!drw
If you get fed twice a day, how bad can life be?



Mon, 19 Apr 1993 17:18:00 GMT  
 call by address (was Re: compilers and linkers)

Quote:

> The [FORTRAN II] language manual pointed out that using constants for
> arguments that were assigned to was invalid.  They wised up when they
> wrote Fortran IV.

Dale, who are "they"?  Anyway, this is an *implementation* bug, not a
design bug.

The RT-11 FORTRAN IV compiler I used on LSI-11 systems as recently as
1982 (RT-11 v4? I'm not sure) still had this bug; I know, I tested it
myself to see.  :-)

...!decvax!decuac!\                                              Phil Kos
  ...!uunet!mimsy!aplcen!osiris!phil           The Johns Hopkins Hospital
...!allegra!/                                               Baltimore, MD



Mon, 19 Apr 1993 11:26:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. call by address (was Re: compilers and linkers)

2. Call a REXX Exec and have it Address the calling program

3. I am looking for email address of Rodney W. Johnson

4. I am away, addresses for problems concerning APL94

5. Am I jumping to address 0x0?

6. Clipper compiler and Linker-HELP

7. Lost Compiler and Linker

8. Problems with Compiler and Linker Using Win95 with FAT32

9. NG compiler/linker

10. C editors, compilers, linkers

11. Pow! Compiler and linker interface DLLs

12. I need a COBOL compiler and linker!

 

 
Powered by phpBB® Forum Software