develooper Front page | | Postings from September 2000

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

Thread Previous | Thread Next
Nathan Wiger
September 19, 2000 19:26
Re: RFC 234 (v1) Data: overloading via the SECOND operand if needed
Message ID:
> ==================================================================
> 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:

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

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

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


Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About