What happens next with OOP in FreeBasic and when? :)

For other topics related to the FreeBASIC project or its community.
Schrubber
Posts: 50
Joined: Dec 07, 2009 11:09

What happens next with OOP in FreeBasic and when? :)

Postby Schrubber » May 04, 2015 9:54

What happens next with OOP in FreeBasic and when? :)

I would be very interested to know how it goes with OOP in FB.

The time it is unfortunately only possible to bequeath a UDT,
It is planned to change that or it stays that way?

Why I want to know that.

I play with the Qt classes around and it would be nice if you
halt both can use OOP's.

Code: Select all

    Type MyClass extends Object, extends FBQObject
      .
      .
     End Type



This is currently not possible, or if you try the lands to try a trick, one in a Segment error!

greeting

Schrubber
caseih
Posts: 1518
Joined: Feb 26, 2007 5:32

Re: What happens next with OOP in FreeBasic and when? :)

Postby caseih » May 04, 2015 13:14

The time it is unfortunately only possible to bequeath a UDT,
It is planned to change that or it stays that way?


What do you mean? Are you talking about single vs multiple inheritance? Multiple inheritance is very hard to get right, so most OO languages that I know of do not allow it. Qt itself is a single-inheritance class library if I'm not mistaken. I'm not sure if FreeBasic supports interfaces or not, but that is sometimes a preferred solution rather than using multiple inheritance.

The only thing FB would need to directly work with Qt C++ classes is the boolean type.
Schrubber
Posts: 50
Joined: Dec 07, 2009 11:09

Re: What happens next with OOP in FreeBasic and when? :)

Postby Schrubber » May 04, 2015 14:29

I mean multiple inheritance.

The Qt Framework is in C ++ written, and C ++ can multiple inheritance, and is also used. Direct access to the libraries would be nice but it is unlikely.

I am thinking of inline stories, templates, operators, to which one has no access.

Code: Select all

  template<typename T> Type; // no way direct
  bool operator ==(const &any ); // no way direct
  bool operator !=(const &any ); //  no way direct
  inline operator < (const &any); // no way direct

  bool operator ==(const &any_1, const &any_2 ); //going
  bool operator != (const &any_1, const &any_2 ); //going


greeting
Schrubber
caseih
Posts: 1518
Joined: Feb 26, 2007 5:32

Re: What happens next with OOP in FreeBasic and when? :)

Postby caseih » May 05, 2015 3:52

To support all those things in that way would make FreeBasic to be essentially a C++ dialect, which has a certain appeal to me. However I'm not sure that's the best course of action. Certainly operator overloading is convenient but it has some serious drawbacks, which is why few languages implement it.

And multiple inheritance is simply hard. When two methods overlap, how do you know on which base class to call the method? Here's an article explaining how Python does it, and it's fairly complicated: http://makina-corpus.com/blog/metier/2014/python-tutorial-understanding-python-mro-class-search-path

Java eschews multiple inheritance in favor of interface contracts, of which any class can implement one or more interface contracts.

I've used Qt for a few projects and while I have inherited from existing Qt classes such as QWindow, I have never needed multiple inheritance. Not saying you don't need it, though.
Schrubber
Posts: 50
Joined: Dec 07, 2009 11:09

Re: What happens next with OOP in FreeBasic and when? :)

Postby Schrubber » May 05, 2015 6:58

It is not my intention that FreeBASIC all the things, the C ++ can.
I think it's just too bad once you get the OOP uses functions, it's just a simple inheritance possible.

There are already ways that you can achieve target, the question is just whether easy or difficult.

greeting
Schrubber
dkl
Site Admin
Posts: 3212
Joined: Jul 28, 2005 14:45
Location: Germany

Re: What happens next with OOP in FreeBasic and when? :)

Postby dkl » May 05, 2015 16:39

Well, g++-compatible multiple inheritance could probably be added to FB. The single-inheritance part of that is already working, and it would just be "extended" (in reality, more like, "rewritten"). It's rather complex though... e.g. the vtable layout, dynamic casts with vptr adjustments, thunks... The BASE keyword must be reworked too, currently it is designed for single inheritance only.

As for a C++-compatible boolean type, there's at least one problem with that: C++ stores 1/0, FB uses -1/0, how should this work? To be compatible, FB's booleans would have to store 1/0.
fxm
Posts: 9820
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Re: What happens next with OOP in FreeBasic and when? :)

Postby fxm » May 05, 2015 16:51

I think that priority is rather the multiple interfaces.
marcov
Posts: 3002
Joined: Jun 16, 2005 9:45
Location: Eindhoven, NL
Contact:

Re: What happens next with OOP in FreeBasic and when? :)

Postby marcov » May 05, 2015 16:55

fxm wrote:I think that priority is rather the multiple interfaces.


If you are going to define your object model in terms of C++, why not go directly for 1:1 mapping?
ike
Posts: 387
Joined: Jan 17, 2011 18:59

Re: What happens next with OOP in FreeBasic and when? :)

Postby ike » May 05, 2015 17:04

As for a C++-compatible boolean type, there's at least one problem with that: C++ stores 1/0, FB uses -1/0, how should this work? To be compatible, FB's booleans would have to store 1/0.


What about FB_Boolean and C_Boolean, and you use what you need?
BasicCoder2
Posts: 3571
Joined: Jan 01, 2009 7:03
Location: Australia

Re: What happens next with OOP in FreeBasic and when? :)

Postby BasicCoder2 » May 05, 2015 17:26

marcov wrote:If you are going to define your object model in terms of C++, why not go directly for 1:1 mapping?

If a version of FreeBasic does that then why not drop all the backward compatibility with QBASIC and previous versions of FreeBasic with a reduced mean and clean BASIC-like version of C++ where you can simply #include the FreeBasic's graphic library? In other words only have the commands that translate 1:1 with C as the basic set while the OO stuff is added as it was with C to C++?
I can translate any of my FreeBasic routines to C++ providing they don't use FreeBasic's graphics or specialized QBASIC stuff like its DRAW command. What would be nice is if I could #include the FreeBasic graphic library in a C++ program for easier translation.
marcov
Posts: 3002
Joined: Jun 16, 2005 9:45
Location: Eindhoven, NL
Contact:

Re: What happens next with OOP in FreeBasic and when? :)

Postby marcov » May 05, 2015 17:30

BasicCoder2 wrote:
marcov wrote:If you are going to define your object model in terms of C++, why not go directly for 1:1 mapping?

If a version of FreeBasic does that then why not drop all the backward compatibility with QBASIC and previous versions of FreeBasic with a reduced mean and clean BASIC-like version of C++ where you can simply #include the FreeBasic's graphic library?


You are confusing binary compatibility with syntax.

I only meant that if C++ compatibility of the object model is a core objective, it doesn't make sense to implement a different MI paradigm.
BasicCoder2
Posts: 3571
Joined: Jan 01, 2009 7:03
Location: Australia

Re: What happens next with OOP in FreeBasic and when? :)

Postby BasicCoder2 » May 05, 2015 21:04

marcov wrote:I only meant that if C++ compatibility of the object model is a core objective, it doesn't make sense to implement a different MI paradigm.

The gaps in my education are showing I guess. As a hobby programmer my self education sort of ended with QBASIC and C using MSDOS which is the reason I am using FreeBasic now. So although I sort of understand the object model I don't have a handle on the terminology used with regards to its implementation. For example I don't know what the MI acronym stands for.
marcov
Posts: 3002
Joined: Jun 16, 2005 9:45
Location: Eindhoven, NL
Contact:

Re: What happens next with OOP in FreeBasic and when? :)

Postby marcov » May 06, 2015 8:43

MI=Multiple Inheritance, the subject of most of this thread :-)
BasicCoder2
Posts: 3571
Joined: Jan 01, 2009 7:03
Location: Australia

Re: What happens next with OOP in FreeBasic and when? :)

Postby BasicCoder2 » May 07, 2015 22:42

marcov wrote:MI=Multiple Inheritance, the subject of most of this thread :-)


:)

Must admit I have never had a hankering for multiple inheritance as a solution in any project I have attempted. It doesn't seem to be included in the teach yourself C++ book I used when learning some C++.

If FreeBasic is going to morph into C++ without the squiggly brackets then it really shouldn't be called BASIC anymore.

One thing about C and C++ there aren't lots of versions to learn and translate. All the programming languages that attach the title of being a BASIC language are incompatible with each other making any attempt at a translation a nightmare. I guess JAVA or C# are idiosyncratic versions of C++ just as the latest version of FreeBasic is an idiosyncratic version of QBASIC however each version is a different language as they add new stuff and remove old stuff found in the older language rather than extending the older language so older programs will still run. So if you have been using multiple inheritance in your programs I guess you would miss it if it wasn't in another language or implemented the same way.
.
Schrubber
Posts: 50
Joined: Dec 07, 2009 11:09

Re: What happens next with OOP in FreeBasic and when? :)

Postby Schrubber » May 08, 2015 9:28

I think every programming language has to evolve!
As well FreeBasic does not take off. I think the MS-QBASIC or MS-PDS never had the potential as FreeBasic! Running stop only on DOS and DOS excuse, is dead and nothing else, thank goodness! Stone me or not that's just my opinion!

FreeBasic never Java, C, C++ or C# will be, it does not have too!
FreeBasic may Library of C, C++, and I think even use Pascal ?!
What more could you want?

If FreeBasic would not run under Linux I would have never used!
And that's what make FreeBasic from among other programming languages.

I hope the dkl and all the others do the great work, go ahead and
developing press ahead as they did with the 64bit support!

I know that there are one or the other, which you do not like what I write, that's just my opinion!

greeting
Schrubber

Return to “Community Discussion”

Who is online

Users browsing this forum: angros47 and 3 guests