[Gambas-devel] About gb.gsl components
Benoît Minisini
gambas at ...1...
Thu Jul 12 00:11:01 CEST 2012
Le 11/07/2012 22:06, Emil Lenngren a écrit :
> Next bug:
> Public Sub Main()
> Dim a As Object = New Complex(2, 1)
> Dim i As Integer
> For i = 1 To 2
> Print a + 2.0
> a = Me
> Next
> End
>
> -> Segmentation fault.
OK, fixed in revision #4944.
>
> And some questions:
> I see that if a class inherits Complex (at least a non-native class),
> the operators are also inherited = good.
> When I implement this in the JIT, can I assume that child classes do not
> override operators, i.e. can I codegen a direct call to the operator (if
> the type is a "pure object")? Or do I have to use virtual dispatching?
>
> /Emil
>
At first sight, I would say that you have to use virtual dispatching, as
nothing prevents a class to reimplement the _operators interface.
But in other way, I don't find any real use of that.
If A inherits B, then being a B implies being an A, so adding Bs should
be handled by the A addition operator.
But we never use inheritance for numbers: otherwise an integer would
inherit a floating point that woul inherit a Complex that would inherit
a Matrix, and everything would be a Matrix internally!
So, even if I would not prevent reimplementing the _operators interface,
I will never do it, and so you can assume that you can do a direct call.
If there is a problem in the future, we'll see...
--
Benoît Minisini
More information about the Devel
mailing list