It is currently Mon Jun 24, 2019 10:57 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 157 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6, 7, 8 ... 11  Next
Author Message
 Post subject: Re: Classes in PureBasic
PostPosted: Tue Feb 05, 2013 1:55 am 
Offline
Enthusiast
Enthusiast

Joined: Tue Apr 24, 2012 5:08 pm
Posts: 542
Location: Ontario, Canada
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. :?:


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.

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


Top
 Profile  
Reply with quote  
 Post subject: Re: Classes in PureBasic
PostPosted: Tue Feb 05, 2013 2:30 am 
Offline
Addict
Addict
User avatar

Joined: Wed Dec 23, 2009 10:14 pm
Posts: 2942
Location: Boston, MA
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.

_________________
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum


Top
 Profile  
Reply with quote  
 Post subject: Re: Classes in PureBasic
PostPosted: Tue Feb 05, 2013 5:26 am 
Offline
Enthusiast
Enthusiast

Joined: Tue Apr 24, 2012 5:08 pm
Posts: 542
Location: Ontario, Canada
skywalk wrote:
But, posting the preprocessed syntax would be meaningless without the preprocessor itself.


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.

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


Top
 Profile  
Reply with quote  
 Post subject: Re: Classes in PureBasic
PostPosted: Tue Feb 05, 2013 9:14 am 
Offline
User
User
User avatar

Joined: Sat Jun 18, 2011 12:20 pm
Posts: 12
Quote:
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

Hm, already forgot reason why '_' was mercylessely kicked by dev team (inculding you) from role of line continuator ? No way:

Code:
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
האם יש זמן לעצור ?


Top
 Profile  
Reply with quote  
 Post subject: Re: Classes in PureBasic
PostPosted: Sat May 04, 2013 1:04 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Tue May 01, 2007 3:49 am
Posts: 109
Location: Institute of Flight Propulsion and Turbomachinery
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:
Code:
Module Engine

  Public Procedure Start(...)
 
  EndProcedure

  Public Module Terrain
 
    Public Procedure Create(...)
   
    EndProcedure
 
  EndModule

EndModule



ImportModule Engine

Engine.Start(...)

Engine.Terrain.Create(...)


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.

_________________
B.Sc. (Mechanical Engineering / Aerospace Engineering)

Free Setup Creator for Windows | 3D Ego Shooter made in PB


Top
 Profile  
Reply with quote  
 Post subject: Re: Classes in PureBasic
PostPosted: Sat May 04, 2013 3:33 pm 
Offline
Enthusiast
Enthusiast

Joined: Tue Apr 24, 2012 5:08 pm
Posts: 542
Location: Ontario, Canada
Forge wrote:
I think that using _ for the scope is just irritating as it may look the function like a globally defined one.......


I agree.

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


Top
 Profile  
Reply with quote  
 Post subject: Re: Classes in PureBasic
PostPosted: Thu Jun 06, 2013 2:45 pm 
Offline
Addict
Addict

Joined: Wed Nov 12, 2008 5:01 pm
Posts: 1040
Location: Russia
Do you plan to appearance of modules in nearest versions of PureBasic?

_________________
Library XP_Menu_Lib - office menu; HID_Lib - USB Library
Torrent client - pbTorrent (source code); Create driver in PureBasic.


Top
 Profile  
Reply with quote  
 Post subject: Re: Classes in PureBasic
PostPosted: Thu Jun 06, 2013 2:57 pm 
Online
Administrator
Administrator

Joined: Fri May 17, 2002 4:39 pm
Posts: 13594
Location: France
Yes


Top
 Profile  
Reply with quote  
 Post subject: Re: Classes in PureBasic
PostPosted: Thu Jun 06, 2013 3:55 pm 
Offline
Addict
Addict
User avatar

Joined: Wed Dec 23, 2009 10:14 pm
Posts: 2942
Location: Boston, MA
Great news!
Will modules be supported without the use of projects?

_________________
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum


Top
 Profile  
Reply with quote  
 Post subject: Re: Classes in PureBasic
PostPosted: Thu Jun 06, 2013 5:04 pm 
Online
Administrator
Administrator

Joined: Fri May 17, 2002 4:39 pm
Posts: 13594
Location: France
Sure.


Top
 Profile  
Reply with quote  
 Post subject: Re: Classes in PureBasic
PostPosted: Thu Jun 06, 2013 5:08 pm 
Offline
Addict
Addict

Joined: Thu Nov 01, 2007 5:37 pm
Posts: 1981
Location: Germany
:shock: That's going to be another awesome release! 8)

_________________
If any of you native English speakers have any suggestions for the above text, please let me know (via PM). Thanks!


Top
 Profile  
Reply with quote  
 Post subject: Re: Classes in PureBasic
PostPosted: Thu Jun 06, 2013 6:22 pm 
Offline
Addict
Addict
User avatar

Joined: Thu Jun 07, 2007 3:25 pm
Posts: 3577
Location: Berlin, Germany
Fred, you are making me very curious. That's unfair. ;-)

_________________
Please excuse my flawed English. My native language is PureBasic.
Search
RSBasic's backups


Top
 Profile  
Reply with quote  
 Post subject: Re: Classes in PureBasic
PostPosted: Thu Jun 06, 2013 7:15 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Sat Dec 03, 2011 5:54 pm
Posts: 736
Location: Oldenburg (Germany)
Fred wrote:
Yes

Cool! :D

_________________
PB 5.70 LTS (x64) - Debian Testing, Gnome 3.30.2


Top
 Profile  
Reply with quote  
 Post subject: Re: Classes in PureBasic
PostPosted: Thu Jun 06, 2013 7:22 pm 
Offline
User
User

Joined: Wed Aug 06, 2008 8:21 am
Posts: 72
User_Russian wrote:
Do you plan to appearance of modules in nearest versions of PureBasic?

Fred wrote:
Yes

Great news! A big thumbs up. :mrgreen:

_________________
PureBASIC v5.41 LTS , Windows v8.1 x64
Forget UNICODE - Keep it BASIC !


Top
 Profile  
Reply with quote  
 Post subject: Re: Classes in PureBasic
PostPosted: Thu Jun 06, 2013 7:25 pm 
Offline
Always Here
Always Here
User avatar

Joined: Thu Jun 24, 2004 2:44 pm
Posts: 5754
Location: Berlin - Germany
:D great news :wink:

_________________
PureBasic 5.70 | SpiderBasic 2.21 | Windows 10 Pro (x64) | Linux Mint 19.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 157 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6, 7, 8 ... 11  Next

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 5 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye