So it appears we’re finally figuring out a solution to the problem here. I will try to summarize:
-
the problem arose trying to extend/customize the behaviour of a Julia object (i.e. a structure+methods, call it
Person
) into another one (call itCitizen
) in a way that it can be used exactly as the base type, except for a few twist (i.e. specialized methods); -
we wanted to solve this problem minimizing as much as possible the number of methods redefined just to forward calls to the base type;
-
minimizing this number implies we had to implement an inheritance-like approach to the problem, and we identified a few rules to be followed (here and here);
-
the inheritance-like approach, however, turned out to be non convenitent as discussed by @ChrisRackauckas here and here. The best, and more Julian way to face this problem is by means of composition, regardless of the number of method to be re-defined;
-
@ScottPJones found what I think is a very nice approach here which uses both composition (in place of inheritance) and minimizes the number of method re-definitions. However, this method requires to re-write the methods in the base class;
-
The real interest for this discusion was the possibility to customize a
DataFrame
object (further discussion here) and refactor the whole package following @ScottPJones solution is not feasible; -
@ChrisRackauckas provided the last piece of information: the
DataFrame
still lacks the definition of an interface which simplifies extending it. Here’s why we had all the problems which ultimately triggered this discussion.
The whole story was absolutely not clear to me when I first started this post, and I’m sorry if everything was obvious to many people here. I learned a lot and wish to thank all of you! :+1