[Gambas-user] How do I override an Array class?

Bruce bbruen at ...2308...
Sun Jun 17 08:22:35 CEST 2012


I would like to override the Variant[] class to extend it with a small
set of special interest methods.

The gambas IDE complains when I try to call my class "Variant[]".

I cannot find anything in the help that seems to preclude this, apart
from the class naming rules.

Is this possible?


(More detail:  I am trying to restructure a large parsing project that
works with hundreds of arrays of tokens, there is a huge amount of
redundant code in it that repeats the same operations on the array.
What I first tried doing was creating a class that inherits Variant[]
and adds a few of the required methods, called "MyVariant". Then going
through the parser project and replacing each As Variant[] with As
MyVariant.  This has raised a problem (of my own making!) where the
classes in the parser inherit others in the project, I need to change
the declarations in each inheritance chain in a single step.  This makes
it fairly difficult to isolate each use of the redundant code and change
it to use the standardised code in MyVariant.
So, I figured that if I could just override the Variant[] class then I
could work on one of the parser classes at a time, clean it up and move
on and not be bugged by the continual compile/fix/compile/fix cycles I
am causing while not even getting far with the real goal.)

Bruce





More information about the User mailing list