[Gambas-user] About OOP features missing on Gambas

Tobias Boege taboege at gmail.com
Sat Jun 8 20:42:03 CEST 2019


On Wed, 05 Jun 2019, Yeshua Rodas wrote:
> Hello coders.
> 
> You'll see, I'm a PHP developer, but I found Gambas fun and enjoyable for
> practice and teaching. However, after days of searching there is some
> issues
> for that I did not found any answer, so here I am asking.
> 
> First: there is no a "PROTECTED" scope? I found tipical Public and Private
> scope for class members on Gambas, but why is not there a Protected scope?
> Or
> is used another key word for that?
> 

There is no such thing. Instead there is a convention (supported by the IDE)
to prefix public members and methods with an underscore to indicate that they
are hidden and using them voids any warranty.

> Second: is there some kind of support for Interfaces? If you see Java or
> PHP
> yo found that for some Abstract Data Types is possible define an Interface,
> you know, a set of public methods that define how an ADT must behave.
> However,
> I do not found any similar on Gambas.
> 

Interfaces (in the sense of making duck typing formal) are not supported
either. The only tool you have is inheritance, and there is no multiple
inheritance.

> Third: Abstract classes? I'm not sure if declaring on a class File "CREATE
> PRIVATE" I am defining a kind of Abstract class.
> 

Create Private means precisely that you cannot create instances of a class.
You can still derive other classes. Providing implementations of methods
and properties *is also* allowed, so depending on what you understand as
an "abstract class" exactly, this may not fit.

You cannot mark a method or property as a "stub", so that a deriving class
which does not implement it causes a "you have to implement abstract ..."
error. You would have to raise those errors yourself in the implementations
of the methods in the abstract parent.

Note that you have to call methods and properties using Me.<something>
in the parent class to have them resolve dynamically (to the actual method
as implemented in the current object inheriting the abstract class)
instead of lexically (to the empty method in the abstract class).

> Fourth: Traits or mixins? this structures allow to languages that only
> support
> simple inheritance a way to reuse a lot of code. I'm thinking that maybe
> using
> Composition over Inheritance can be a solution, but I'm just aware if
> traits
> or mixins can be supported on Gambas.
> 

No such thing.

Benoît is on record saying that these features are missing in Gambas
because the "bas" in Gambas comes from "BASIC". Introducing all these
Java- and C++-esque features are very much not that.

Regards,
Tobi

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk


More information about the User mailing list