[Gambas-user] Inheriting, wrapping and casting

Tobias Boege taboege at ...626...
Sat Apr 19 20:40:39 CEST 2014


On Sat, 19 Apr 2014, Bruno F??lix Rezende Ribeiro wrote:
> Em Sat, 19 Apr 2014 01:07:21 +0200
> Tobias Boege <taboege at ...626...> escreveu:
> 
> > Oh, I forgot to ask: do you want the patch that allows inheritance-
> > compatible[*] classes to be used in place of a class in method and
> > property signatures to test the above approach - even if it's
> > unlikely that it goes mainline?
> 
> Sure!

Attached. But be warned (again?): the interpreter is actually not my
business. Virtually, I don't even know what I've done to the code as an
entire with my patch but it worked in the single test case I had.

I tested code like this to have VariantArray implement Extract() and it
succeeded:

Public Sub Extract(Start As Integer, Optional Length As Integer = 1) As VariantArray
  Dim hNew As New VariantArray
  Dim vElt As Variant

  For Each vElt in Super.Extract(Start, Length)
    hNew.Add(vElt)
  Next
  Raise ExtractEvent
  Return hNew
End

Note that VariantArray.Extract(), just like Variant[].Extract(), returns
a new object which has, by default, no event name. So don't be surprised
if the returned object doesn't fire any events. You have to manually assign
it to an event observer using Object.Attach(). Another reason against giving
events to data containers ;-)

> 
> Thank you very much for your efforts coding on the interpreter.

Well, that's pretty much the only thing I can do when Benoit is not around
to answer those core questions (which is seldom the case anyway).

Regards,
Tobi

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk
-------------- next part --------------
A non-text attachment was scrubbed...
Name: looser-inheritance-signature-checking.patch
Type: text/x-diff
Size: 997 bytes
Desc: not available
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20140419/692ae4f2/attachment.patch>


More information about the User mailing list