Calling Conventions and Pass By Reference

Simon Wistow simon at thegestalt.org
Tue Sep 2 20:13:12 BST 2008


On Tue, Sep 02, 2008 at 09:43:32PM +0300, Yuval Kogman said:
> but conversly you have:
> 
> 	my $x = 3;
> 	my $y = $x;
> 	$x++;
> 	$y; # 4
> 
> IIRC python works like that.

There was an interesting paper a while back [goes off to find it ... 
AHAH]

http://www.cs.mdx.ac.uk/research/PhDArea/saeed/

about the cognitive models used when learning to program.

Students are asked questions like

    a=10
    b=4
    c=a+b

    What is the value of c?


And then

    a=10
    b=4
    c=a+b
    a=20

    Now what is the value of c?

For the first example, the answer is pretty clearly 14 but for the 
second the answer could arguably be either 14 *or* 24.

I think most programmers are going to go with 14 but I wonder if a 
totally pass by reference language would cause effects that would mean 
that you would get used to it being 24. 

More importantly - if that happened would it even matter? Would old 
programmers have a problem with it but new programmers just adapt?

Simon





More information about the london.pm mailing list