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

Benoît Minisini gambas at ...1...
Sun Jun 17 15:45:33 CEST 2012


Le 17/06/2012 08:22, Bruce a écrit :
> 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
>

You can't override Variant[] because '[' and ']' are not allowed in 
project file names.

You can do that by creating the source file by hand, but you may have 
problems - This is the reason why it is forbidden. :-)

I don't see what the real problem is with replacing all occurences of 
Variant[] by something like "MyTokenArray".

-- 
Benoît Minisini




More information about the User mailing list