From: Jim Freeze Date: 2002-12-15T00:38:41+09:00 Subject: Re: Is it wise to extend Matrix? On Saturday, 14 December 2002 at 22:36:11 +0900, Gavin Sinclair wrote: > Since the thread "Inheritance question" has become so deep (physically :) and > my point is sort of orthoganal to it, new thread. > > In Jim's case, he wanted to add some methods to Matrix. Well, he didn't want > to change Matrix directly, but the methods he was going to add would in no way > be out of place in the real Matrix class, so to me, inheritance is the wrong > approach. Delegation is the key here. Create a new class based on Matrix, add > your methods, and forget that Matrix ever existed. > > Of course, I think there are some implementation problems he had with the type > that was returned from some methods - I lost track. But maybe he can come up > with a new kind of delegation that solves that. Yes, that is what I want. The Matrix class has a sticky issue since it uses a class method constructor. But, if I overlook that temporarily, I think the delegator class would need the ability to wrap functions that were chainable and return self. I believe it is as simple as that. But I have not come up with a good syntax for that and I don't think I have had the 'ah-ha' moment about delegators yet. -- Jim Freeze