[Gambas-user] About OOP features missing on Gambas

Yeshua Rodas yrodas at upnfm.edu.hn
Wed Jun 12 04:34:31 CEST 2019


Thank you. All is more clear for me now.

However, I'm facing an issue that I'm not sure how to handle it.

I have a basic class with a method:

Public Function doSomething(param as SomeBaseClass) as String
  ' Some stuff
End


And a derivated class that I need to call some specialized method

Public Function doSomething(param as SomeDerivatedClass) as String
  ' Some stuff
  param.childMethod()
  ' More stuff
End


But this rise "Symbol is badly overridden" error.
I think that on overriding would be useful to override the type for an
inherited type. The actual constraint model is squeezing my brain.

Regards.

El sáb., 8 jun. 2019 a las 12:43, Tobias Boege (<taboege at gmail.com>)
escribió:

> 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
>
> ----[ Gambas mailing-list is hosted by https://www.hostsharing.net ]----
>


-- 
E. Yeshua Rodas
DTI - UPNFM
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.gambas-basic.org/pipermail/user/attachments/20190611/87dba6d9/attachment.html>


More information about the User mailing list