develooper Front page | perl.perl6.language.data | Postings from September 2000

Re: logical ops on arrays and hashes

Thread Previous
From:
Dan Sugalski
Date:
September 13, 2000 13:30
Subject:
Re: logical ops on arrays and hashes
Message ID:
5.0.0.25.0.20000913162044.01fe4d40@24.8.96.48
At 09:49 AM 9/13/00 +1200, Christian Soeller wrote:
>It's probably just me but I thought (1) just creating an object leaves
>me handing around scalars

That's likely not to be the case in p6. You should be able to overload the 
operations for arrays and hashes, and ought to be able to do objectish 
things with them. (Though they may not actually be 'objects' in the full 
perl sense)

>  (2) tie doesn't let me modify those
>polymorphic methods (or does it? and what's the syntax with multi-dims
>anyway), so there. What I might want to do is overload ADD for a
>multi-dim array @a. How would I go about it while preserving the array
>syntax?

Just overload the array. Your ADD (or whatever it gets called) method will 
be called when you do math with your overloaded array.

					Dan

--------------------------------------"it's like this"-------------------
Dan Sugalski                          even samurai
dan@sidhe.org                         have teddy bears and even
                                      teddy bears get drunk


Thread Previous


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