develooper Front page | perl.perl6.language | Postings from June 2005

Assigning Proxy objects

Thread Next
From:
Ingo Blechschmidt
Date:
June 14, 2005 05:39
Subject:
Assigning Proxy objects
Message ID:
loom.20050614T142439-761@post.gmane.org
Hi, 
 
  sub proxy () is rw { 
    return new Proxy: 
      FETCH => { 42 }, 
      STORE => -> $new { 23 }; 
  } 
 
  say proxy();        # 42 
  say proxy() = 40;   # 40, 23, or 42? 
 
Currently I think the last line should output 40, consider: 
 
  sub innocent_sub ($var is copy) { 
    my $foo = ($var = 40); 
    # Do something with $foo, relying on $foo being 40. 
  } 
 
  { my $x = "does not matter"; innocent_sub $x } 
  # Works 
 
  { my $x := proxy(); innocent_sub $x } 
  # Would break if (proxy() = 40) would not return 40. 
 
But I can argue that the return value of Proxy object should 
be the return value of the code given by FETCH in the Proxy 
object construction, too... 
 
Opinions? 
 
--Ingo 
 
--  
Linux, the choice of a GNU | To understand recursion, you must first 
generation on a dual AMD   | understand recursion.   
Athlon!                    | 


Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About