[Gambas-user] Inheritance and Signature checking in gambas 3

Bruce Bruen bbruen at ...2308...
Tue Sep 20 04:18:37 CEST 2011


On Tue, 2011-09-20 at 03:06 +0200, Benoît Minisini wrote:


> Mmm. You should provide your code, or some schema, so that I am sure to really 
> understand your design.
> 
> Now I will try to give you solution, but I'm not sure it is good as I'm not 
> sure that I understood your description completely.
> 
> So...
> 
> 1) Not ensuring that the signatures of a child method is exactly the same as 
> the parent method was a Gambas 2 bug that can lead to interpreter crashes.
> 
> 2) In other words, as soon as a parent class A has a Marshall() method, a 
> children class B that overrides Marshall() must use the same signature. The 
> contrary is, for me, completely illogical.
> 
> 3) If you want the children class to all have different Marshall() signatures, 
> then Marshal() cannot be a member of the parent class.
> 
> 4) So I suggest that you rename all Marshal() child methods into something 
> like "_Marshal()". And that you keep a Marshal(...) in the parent class that 
> will call the _Marshal() method *dynamically* by using the Object.Call() 
> method. Something like that:
> 
> 	Public Sub Marshal(...)
> 	
> 	  Dim aParam As New Variant[Param.Count]
> 	  Dim I As Integer
> 	
> 	  ' I realise that a Param.All property would be a good idea!
> 	  For I = 0 To Param.Max
> 	    aParam[I] = Param[I]
> 	  Next
> 	
> 	  Object.Call(Me, "_Marshal", aParam)
> 	
> 	End
> 
> Regards,
> 
> -- 
> Benoît Minisini
> 

Thanks, for looking at this (again) Benoît.  I will build a simplified
set of the structures and post it (it is just too big at 18 or so
components to post as one chunk) over the next few days.  I'll also have
a look at your note 4 and see if that provides a way around the
problem. 

But regarding note 1) "Not ensuring that the signatures of a child
method is exactly the same as the parent method was a Gambas 2 bug that
can lead to interpreter crashes."  This is the bit I don't understand.
In the hundreds if not thousands of lines of code in my gambas2
projects, I have never seen it crash in this way.  As I said these
projects have been running for several years.  

And as to note 2) "The contrary is, for me, completely illogical."  I
must disagree,  method overriding is a well known object oriented design
aspect.  (And I know you know :-) as you have said yourself in a comment
in issue 78 "And the check is not done too for a native class inheriting
another native class. C/C++ programmer are supposed to know what they
are doing. :-)"  ).    

regards
Bruce





More information about the User mailing list