[Gambas-user] New Syntax, SUPER && !comprehension(mine) Re.: SUPER example at gambasdoc

Benoît Minisini gambas at ...1...
Thu May 8 15:35:37 CEST 2014


Le 08/05/2014 15:00, Stephen a écrit :
>     Looking at the thread "New syntax for using variables arguments in a
> function call" I realized that I needed to really brush up on my
> somewhat marginal understanding of the evolving (a good thing) GAMBAS
> and OOP. Not fully understanding "SUPER" (I've never used it but can see
> a use for it) I trotted off to Google and the GAMBAS documentation,
> where much reading was done, and (as usual) more questions raised.
>     Studying the "SUPER" example at http://gambasdoc.org/hemp/lang/super,
> I wondered at the purpose of a collection that seems not to be used but
> once and some syntax in it's use in the example, which didn't make any
> sense to my old brain. Below is a snippet from the example (where $cPos
> is a collection, $aKey an Array of String Objects (I think) and Key a
> string object;
>
> $cPos.Clear
> $cPos[Key] = $aKey.Count
> $aKey.Add(Key)
>
>     OK, the first line clears the collection, got it, and the last line
> adds the contents of "String" to $aKey, got that.... but what does the
> second line do? It looks like it is adding the count of elements in
> $aKey to the collection $cPos... but in OOP I would use a method call
> i.e. $cPos.Add(Key,Key). Oh, and in trying to implement the example
> GAMBAS (3.5.3) complained that "ListBox.Add is incorrectly overridden".
>

SUPER is a standard keyword in OOP. It represents the parent class of 
the class of the current object.

I have fixed the example in the wiki (now at http://gambaswiki.org). Not 
that example is not complete, it just shows how to use SUPER.

But it does not exist in all OOP languages. For example, in C++, you 
have to name the parent class explicitely.

Regards,

-- 
Benoît Minisini




More information about the User mailing list