Page 5 of 11

Re: Classes in PureBasic

Posted: Tue Feb 05, 2013 1:55 am
by BorisTheOld
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.

Re: Classes in PureBasic

Posted: Tue Feb 05, 2013 2:30 am
by skywalk
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.

Re: Classes in PureBasic

Posted: Tue Feb 05, 2013 5:26 am
by BorisTheOld
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

Re: Classes in PureBasic

Posted: Tue Feb 05, 2013 9:14 am
by Guevara-chan
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: 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 ?

Re: Classes in PureBasic

Posted: Sat May 04, 2013 1:04 pm
by X0r
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: Select all

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.

Re: Classes in PureBasic

Posted: Sat May 04, 2013 3:33 pm
by BorisTheOld
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.

Re: Classes in PureBasic

Posted: Thu Jun 06, 2013 2:45 pm
by User_Russian
Do you plan to appearance of modules in nearest versions of PureBasic?

Re: Classes in PureBasic

Posted: Thu Jun 06, 2013 2:57 pm
by Fred
Yes

Re: Classes in PureBasic

Posted: Thu Jun 06, 2013 3:55 pm
by skywalk
Great news!
Will modules be supported without the use of projects?

Re: Classes in PureBasic

Posted: Thu Jun 06, 2013 5:04 pm
by Fred
Sure.

Re: Classes in PureBasic

Posted: Thu Jun 06, 2013 5:08 pm
by c4s
:shock: That's going to be another awesome release! 8)

Re: Classes in PureBasic

Posted: Thu Jun 06, 2013 6:22 pm
by Little John
Fred, you are making me very curious. That's unfair. ;-)

Re: Classes in PureBasic

Posted: Thu Jun 06, 2013 7:15 pm
by uwekel
Fred wrote:Yes
Cool! :D

Re: Classes in PureBasic

Posted: Thu Jun 06, 2013 7:22 pm
by marroh
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:

Re: Classes in PureBasic

Posted: Thu Jun 06, 2013 7:25 pm
by ts-soft
:D great news :wink: