Classes in PureBasic
Got an idea for enhancing PureBasic? New command(s) you'd like to see?
- BorisTheOld
- Enthusiast
Enthusiast - Posts: 542
- Joined: Tue Apr 24, 2012 5:08 pm
- Location: Ontario, Canada
Re: Classes in PureBasic
Post by BorisTheOld »
Obviously, my sample class does compile, but only as part of a greater class and with the benefit of 114 macros that hide the clutter of PB's syntax.skywalk wrote:Hi Boris,
I agree with you, but your postings do nothing to affirm your "classy" statements.
They might as well be written in another language if they don't compile. :?:
The point of the exercise was to show the general structure of a class and to show that classes can be implemented. The point was not to show how to do it, since anyone who knows what a class is can put together the elements in a couple of days. And those who don't know what a class is should do some reading first. After which, they too could put together the elements in a couple of days.
For ten years Caesar ruled with an iron hand, then with a wooden foot, and finally with a piece of string.
~ Spike Milligan
~ Spike Milligan
Re: Classes in PureBasic
No disrespect intended as I did say I agree with your statements.
But, it would be helpful if you prefix such code posts with "non-working snippet".
Best not to assume the experience level of your audience. :wink:
I've written several thousand lines of code that "writes" code.
But, posting the preprocessed syntax would be meaningless without the preprocessor itself.
But, it would be helpful if you prefix such code posts with "non-working snippet".
Best not to assume the experience level of your audience. :wink:
I've written several thousand lines of code that "writes" code.
But, posting the preprocessed syntax would be meaningless without the preprocessor itself.
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
- BorisTheOld
- Enthusiast
Enthusiast - Posts: 542
- Joined: Tue Apr 24, 2012 5:08 pm
- Location: Ontario, Canada
Re: Classes in PureBasic
Post by BorisTheOld »
The example that I posted was real PB code, ready to be compiled -- no preprocessing required. It demonstrates how PB can be used to create structured, readable, OOP code.skywalk wrote:But, posting the preprocessed syntax would be meaningless without the preprocessor itself.
Implementation is left as an exercise for the reader. :D
For ten years Caesar ruled with an iron hand, then with a wooden foot, and finally with a piece of string.
~ Spike Milligan
~ Spike Milligan
- Guevara-chan
- User
User - Posts: 13
- Joined: Sat Jun 18, 2011 12:20 pm
Re: Classes in PureBasic
Post by Guevara-chan »
Hm, already forgot reason why '_' was mercylessely kicked by dev team (inculding you) from role of line continuator ? No way:Btw, another reason for the '_': #MyConstant inside Module Foo becomes "#Foo_MyConstant" which looks good. "Foo::#MyConstant" or "#Foo::MyConstant" are both a bit weird imho
Code: Select all
Module _ ; Show me any rule to not do it ?
External __.a ; Show me any rule to not do it ? x2
EndModule
Module __ ; Show me any rule to not do it ? x3
External _.a ; Show me any rule to not do it ? x4
EndModule
Debug ____ ; Where is thine God now ?
life MOV.I #life+1, *life
האם יש זמן לעצור ?
האם יש זמן לעצור ?
Re: Classes in PureBasic
Interesting discussion. Here is an old pseudo code I posted in the German forums a few years ago illustrating a possible use of modules in PB:
I think that using _ for the scope is just irritating as it may look the function like a globally defined one, just with a prefix added. So this would be just a kind of "semantic" implementation but I think we need a proper syntax for the modules in order to be able to distinguish between a module function call and a normal function call.
Code: Select all
Module Engine
Public Procedure Start(...)
EndProcedure
Public Module Terrain
Public Procedure Create(...)
EndProcedure
EndModule
EndModule
ImportModule Engine
Engine.Start(...)
Engine.Terrain.Create(...)
- BorisTheOld
- Enthusiast
Enthusiast - Posts: 542
- Joined: Tue Apr 24, 2012 5:08 pm
- Location: Ontario, Canada
Re: Classes in PureBasic
Post by BorisTheOld »
I agree.Forge wrote:I think that using _ for the scope is just irritating as it may look the function like a globally defined one.......
We use "_" in constant names, so if PB uses "_" in namespace references there is always the risk of name conflicts.
FreeBasic implements namespaces in a way that is very similar to the "With" statement, and uses the "." notation for referencing data and procedures. There is a description in the FreeBasic user manual.
A FreeBasic namespace does not represent a "black box" like a class or DLL, but is strictly a method of grouping related data and procedures without the need to prefix the names with a unique identifier. All data and procedures not in a namespace are assumed to be in an unnamed global namespace.
For ten years Caesar ruled with an iron hand, then with a wooden foot, and finally with a piece of string.
~ Spike Milligan
~ Spike Milligan
- User_Russian
- Addict
Addict - Posts: 1582
- Joined: Wed Nov 12, 2008 5:01 pm
- Location: Russia
Re: Classes in PureBasic
Post by User_Russian »
Do you plan to appearance of modules in nearest versions of PureBasic?
Re: Classes in PureBasic
Great news!
Will modules be supported without the use of projects?
Will modules be supported without the use of projects?
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
- Little John
- Addict
Addict - Posts: 4801
- Joined: Thu Jun 07, 2007 3:25 pm
- Location: Berlin, Germany
Re: Classes in PureBasic
Post by Little John »
Fred, you are making me very curious. That's unfair. ;-)
Re: Classes in PureBasic
User_Russian wrote:Do you plan to appearance of modules in nearest versions of PureBasic?
Great news! A big thumbs up. :mrgreen:Fred wrote:Yes
PureBASIC v5.41 LTS , Windows v8.1 x64
Forget UNICODE - Keep it BASIC !
Forget UNICODE - Keep it BASIC !
- ts-soft
- Always Here
Always Here - Posts: 5756
- Joined: Thu Jun 24, 2004 2:44 pm
- Location: Berlin - Germany
Re: Classes in PureBasic
:D great news :wink:
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
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
Return to "Feature Requests and Wishlists"
Jump to
- PureBasic
- ↳ Coding Questions
- ↳ Game Programming
- ↳ 3D Programming
- ↳ Assembly and C Programming in PureBasic
- ↳ The PureBasic Editor
- ↳ The PureBasic Form Designer
- ↳ General Discussion
- ↳ Feature Requests and Wishlists
- ↳ Tricks 'n' Tips
- Bug Reports
- ↳ Bugs - Windows
- ↳ Bugs - Linux
- ↳ Bugs - Mac OSX
- ↳ Bugs - C backend
- ↳ Bugs - 3D Engine
- ↳ Bugs - IDE
- ↳ Bugs - Documentation
- OS Specific
- ↳ AmigaOS
- ↳ Linux
- ↳ Windows
- ↳ Mac OSX
- ↳ Raspberry PI
- Miscellaneous
- ↳ Announcement
- ↳ Off Topic
- Showcase
- ↳ Applications - Feedback and Discussion
- ↳ PureFORM & JaPBe
- ↳ TailBite