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

Binding and the Proxy class

Thread Next
From:
Ingo Blechschmidt
Date:
April 23, 2005 10:42
Subject:
Binding and the Proxy class
Message ID:
d4e158$u7s$1@sea.gmane.org
Hi,

  my $x = new Proxy: FETCH => { foo() }, STORE => { bar($^new) };
  $x ~~ Proxy; # true
  $x = 42;     # neither foo nor bar called
  $x ~~ Num;   # true

  my $y := new Proxy: FETCH => { foo() }, STORE => { bar($^new) };
  $y ~~ Proxy; # false (unless foo returns a Proxy object)
  $y = 42;     # bar(42) called
  $y ~~ Proxy; # still false (unless foo returns a Proxy object)
  say $y;      # foo() called

Correct?

BTW, is it possible to implement the Proxy class in pure Perl? (I don't
think so.)

--Ingo

-- 
Linux, the choice of a GNU | Row, row, row your bits, gently down the
generation on a dual AMD   | stream...  
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