On Thu, 26 Feb 2004 13:30:52 +0100, Robert Klemme <bob.news / gmx.net> wrote:

>> Another problem (which is much harder to solve) is: What kind of object
>> should receive the *= message in the case of the "Float = Vector *
> Vector"
>> operation?
>
> Clearly the result of #op_dup.  First a copy is created and then the
> inplace operation is performed.

Well, yes, but what kind of object should #op_dup return? It would have to 
be a Float, because that's the result of the operation, but upon receiving 
the first #*= message it would have to multiply two Vectors, while for 
later #*='s it would have to act like an ordinary Float.
Possible, but not exactly what I would like to do.

>> I think the closest you could ever get to this would be the current ruby
>> way (ie. defining #+= using #+) and optionally being able to define your
>> own #+= as well.
>
> ... or the other way round, i.e. defining #+ using #+= and optionally
> defining #+ as well.

True, of course.
There is a disadvantage to both, though: It would be ugly to inhirit from 
such a class and trying to change the behaviour of #+ and #+=, as you can 
never be sure that it is enough to just overwrite one method, so you'll 
always need to overwrite both.

-- 
exoticorn/farbrausch