Mutability 
Author Message
 Mutability

I seem to recall hearing that early versions of fortran would accept
statements like

   3 = 4

and interpret them as specifying that the constant "3" should have the
value "4" from now on.



Sun, 16 Jul 1995 22:46:06 GMT  
 Mutability

Quote:
>I seem to recall hearing that early versions of Fortran would accept
>statements like

>   3 = 4

>and interpret them as specifying that the constant "3" should have the
>value "4" from now on.

Actually what I had heard was that some older compilers would let you pass
constants into a routine in the place of a variable that was passed by
address.
It did this because all numeric constants were stored in fixed memory locations
and then referenced by address rather than value...
Anyway, If the called procedure then changed the variable, it would change
the global place where that constant was stored, rendering 3=4 for the rest of
the program...

(In Pascal :: my Pop is too rusty...
 the following program would output the number 5
)

program(input,output);

procedure callfoo;
var a : integer;
begin
        foo(3);
        a := 1;
        writeln(a+3);
end;

procedure foo (var bob:integer);
begin
        bob := 4 ;
end;
begin
        callfoo;
end.




Wed, 19 Jul 1995 06:36:01 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Mutability of literals in R5RS

2. Extending python & mutability

 

 
Powered by phpBB® Forum Software