"Dennis Ranke" <dennis.ranke / epost.de> schrieb im Newsbeitrag news:opr3y90tet4wwk8i / News.CIS.DFN.DE... > 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. Especially since a Float typically does not have a method for multiplying it with a Vector. Does #coerce help here? > >> 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. Yeah, exactly. I think, that's why I like the approach it is today. Still not really satisfying. I see the disadvantages of both sides clearer now, but I don't see a better solution right now. :-( Maybe we'll see multiple dispatch in Ruby 3 and then these things get easier. :-) Again, thanks for sorting that out! Regards robert