[Gambas-user] About OOP features missing on Gambas

Jussi Lahtinen jussi.lahtinen at gmail.com
Fri Jun 14 19:39:08 CEST 2019

This is pretty much my beef with OOP (however, I do see its benefits and
Gambas is great language!). More you rely on OOP features (in contrast to
example features of procedural languages), more you make your code
invisibly language specific. There doesn't seem to be proper common OO
language standards and the "rules" are not intuitive nor derivable. IE it
is not clear what superficially the semantically same code does in two
different OO languages.

Thus I would suggest not to add features that lack de facto standards,
unless they are really powerful and widely useful.


On Fri, Jun 14, 2019 at 1:41 PM Tobias Boege <taboege at gmail.com> wrote:

> On Tue, 11 Jun 2019, Yeshua Rodas wrote:
> > 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.
> >
> Allowing that seems sensible to me. You'll have to get Benoît's attention
> to have it implemented though.
> But note that Gambas does not have polymorphic methods, so with the above
> you will essentially forbid someone to use the derived class's doSomething
> like they could with the parent class, because the signature is irrevocably
> more constrained. To me, this seems like a violation of Liskov's
> substitution
> principle, which you may care about or not.
> Also note that you can put an object of type B into a variable typed A
> *and get it out again* into a variable typed B, provided that the actual
> type of the object is B and B inherits A. An object does not lose its
> "true type" by being placed in a typed variable. A variable's type acts
> mostly like a method lookup table for the contained object, which you
> can switch out as long as they are compatible via inheritance.
>   Public Function doSomething(param As SomeBaseClass) As String
>     Dim der As SomeDerivatedClass = param
>     der.childMethod()
>   End
> in SomeDerivatedClass will work right now without raising the
> "badly overridden" error. Put in a Try and a call to Super.doSomething
> and you have manually constructed a method that is polymorphic along
> class lineage. The other solution that works right now would be to name
> the new method differently.
> Regards,
> Tobi
> --
> "There's an old saying: Don't change anything... ever!" -- Mr. Monk
> ----[ Gambas mailing-list is hosted by https://www.hostsharing.net ]----
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.gambas-basic.org/pipermail/user/attachments/20190614/5a9b1f54/attachment.html>

More information about the User mailing list