Classes in PureBasic

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
rsts
Addict
Addict
Posts: 2736
Joined: Wed Aug 24, 2005 8:39 am
Location: Southwest OH - USA

Re: Classes in PureBasic

Post by rsts »

What's a "module"?
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Re: Classes in PureBasic

Post by ts-soft »

rsts wrote:What's a "module"?
A module have protected var-, procnames, like a userlib.
You can export vars, functions and so on.

No more conflicts in includes, if you use module.
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
User avatar
bembulak
Enthusiast
Enthusiast
Posts: 575
Joined: Mon Mar 06, 2006 3:53 pm
Location: Austria

Re: AW: Classes in PureBasic

Post by bembulak »

Linke a 'unit' in Pascal.
Great news btw.
cheers,

bembulak
User_Russian
Addict
Addict
Posts: 1518
Joined: Wed Nov 12, 2008 5:01 pm
Location: Russia

Re: Classes in PureBasic

Post by User_Russian »

Can make a class, very similar to module.

Code: Select all

DeclareClass Test
  ; Public elements.
  Global x.l
  Global y.l
  Declare Plus()

EndDeclareClass


Class Test
  ; Private elements.
  Global z.l
  
  Procedure Plus()
    Result = x + y
    z + Result
    ProcedureReturn Result
  EndProcedure

EndClass



x.Test ; Create an instance of class.
x\x=2
x\y=8
Debug x\Plus() ; Return value 10.
User avatar
Shield
Addict
Addict
Posts: 1021
Joined: Fri Jan 21, 2011 8:25 am
Location: 'stralia!
Contact:

Re: Classes in PureBasic

Post by Shield »

So not gonna happen. :lol:
Image
Blog: Why Does It Suck? (http://whydoesitsuck.com/)
"You can disagree with me as much as you want, but during this talk, by definition, anybody who disagrees is stupid and ugly."
- Linus Torvalds
User_Russian
Addict
Addict
Posts: 1518
Joined: Wed Nov 12, 2008 5:01 pm
Location: Russia

Re: Classes in PureBasic

Post by User_Russian »

Well, why not? This corresponds to the concept of PB and if Fred and the team will do so, it would be great.
Time is now, programming in style OOP, complicated and confusing.
User avatar
Shield
Addict
Addict
Posts: 1021
Joined: Fri Jan 21, 2011 8:25 am
Location: 'stralia!
Contact:

Re: Classes in PureBasic

Post by Shield »

User_Russian wrote:Well, why not?
Because Fred doesn't want to. As sad as this is, it won't happen any time soon.
There haven been discussions about adding OO support for years, the answer has always been the same.

This was the reason I switched to other languages that are more suitable to satisfy my needs.
Image
Blog: Why Does It Suck? (http://whydoesitsuck.com/)
"You can disagree with me as much as you want, but during this talk, by definition, anybody who disagrees is stupid and ugly."
- Linus Torvalds
mestnyi
Addict
Addict
Posts: 1098
Joined: Mon Nov 25, 2013 6:41 am

Re: Classes in PureBasic

Post by mestnyi »

For this reason, I have moved on to other languages​​,

What if not a secret?
User_Russian
Addict
Addict
Posts: 1518
Joined: Wed Nov 12, 2008 5:01 pm
Location: Russia

Re: Classes in PureBasic

Post by User_Russian »

Shield wrote:Because Fred doesn't want to.
Fred creates a PB, just for yourself?
PB and so is not very popular. Need to listen to the views community, and implement modern features of a programming language.
Fred
Administrator
Administrator
Posts: 18153
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: Classes in PureBasic

Post by Fred »

So we have to listen to you ? Not everybody wants OOP, and PB won't have a OOP built-in, it's a design choice and I have made it clear a lot of time on this forum. If you don't like it, do as Shield did, find a tool which fits your needs better.
User avatar
skywalk
Addict
Addict
Posts: 4210
Joined: Wed Dec 23, 2009 10:14 pm
Location: Boston, MA

Re: Classes in PureBasic

Post by skywalk »

Fred, would you consider another language spinoff like PooBasic? :idea:
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
Fred
Administrator
Administrator
Posts: 18153
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: Classes in PureBasic

Post by Fred »

PooBasic, really ??????? :twisted:
User avatar
skywalk
Addict
Addict
Posts: 4210
Joined: Wed Dec 23, 2009 10:14 pm
Location: Boston, MA

Re: Classes in PureBasic

Post by skywalk »

I was half kidding. :wink:
The other half was serious. I want to import C++ libs without extern C wrappers. :idea:
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
Fred
Administrator
Administrator
Posts: 18153
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: Classes in PureBasic

Post by Fred »

It should may be possible trough special interfaces, so it doesn't requiers built-in OOP.
User avatar
skywalk
Addict
Addict
Posts: 4210
Joined: Wed Dec 23, 2009 10:14 pm
Location: Boston, MA

Re: Classes in PureBasic

Post by skywalk »

Ah, that would be awesome. :shock:
The list of C++ libs are growing and not always support extern C.

Forgive my ignorance of features that are OOP limited.
Is the lack of operator and procedure overloading OOP related also?
It is a nuisance to write multiple copies of Procedures just to handle different datatypes.
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
Post Reply