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

Re: logical ops on arrays and hashes

Thread Previous | Thread Next
From:
Jeremy Howard
Date:
September 12, 2000 16:21
Subject:
Re: logical ops on arrays and hashes
Message ID:
000901c01d10$55d30970$d5252ccb@optimaldecisions.com
Christian Soeller wrote:
> Jeremy Howard wrote:
> >
> > <Removed -language x-post>
> >
> > > Wouldn't it be very useful if all of the applicable polymorphic
methods
> > > of RFC 159 would be overloadable for nD arrays (arrays becoming
> > > effectively instances of array objects)? I am not sure if this has
been
> > > discussed before but I could think of a whole lot of applications.
Often
> > > you might want to do just that with the suggested multidim arrays. Or
is
> > > that already suggested in some other way?
> > >
> > Arrays are just lists of lists that happen to be declared with a simple
> > type. They are not objects.
> >
> > Creating an array-like object with different behaviour could be achieved
> > through tie(), or by creating an object with RFC 159 methods defined.
> >
> > ...Or am I missing something here?
>
> It's probably just me but I thought (1) just creating an object leaves
> me handing around scalars (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?
>
Yeah, it's just you ;-)

In <RFC 200--Objects: Revamp tie to support extensibility (Massive tie
changes)>, you can use the RFC 159 methods on tied implementations:

  http://tmtowtdi.perl.org/rfc/200.html#Function_Summary

<quote>
   Other Methods
   -----------------------------------------------------
   Include all other methods described in RFC 159
</quote>



Thread Previous | 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