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

Re: RFC 234 (v1) Data: overloading via the SECOND operand if needed

Thread Previous | Thread Next
From:
Nathan Wiger
Date:
September 19, 2000 19:26
Subject:
Re: RFC 234 (v1) Data: overloading via the SECOND operand if needed
Message ID:
39C81E30.F928B838@wiger.org
> ==================================================================
> Either way I'm not sure it solves the problem; if each module asserts
> that *they* are the smarter one then you either wind up with the same
> situation you have now or even worse contention.
> ==================================================================
> 
> Yes.  So do not do this.

My concern was not if you have control over both modules, but what if
you don't?

Then you need a way to say ":override_the_override". But then you're
back at square one.

Python has a neat method called C<__radd__> which acts when it's the
right argument in +, and to my understanding allows two classes to
interoperate in some situations. You might want to check it out if
you're not familiar with it:

http://www.python.org/doc/2.0b1/ref/numeric-types.html

There are C<__r*__> methods for all of the binary ops. 

Finally, rather than being implemented in terms of single ":override"
tag, I think a better way might be to attach attributes to the special
subs:

   sub ADD : override('Math::BigInt') {   }
   sub DIV { }
   sub MUL : override(__ALL__) {  }

Because you may not want to override all operations for a class.

-Nate

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