OOP Support (it is time)

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
User avatar
TomS
Enthusiast
Enthusiast
Posts: 342
Joined: Sun Mar 18, 2007 2:26 pm
Location: Munich, Germany

Re: OOP Support (it is time)

Post by TomS »

Foz wrote:I prefer the syntax of SimpleOOP, for one reason: procedures in the classes (I can relate to that syntax due to using VB.net at work)
Wait. I thought that was standard, or what do you mean with Procedure inside Class?

Code: Select all

Class myObject
    Procedure Init(); Or whatever it's called in simpleOOP (in php eg. it's __construct() )
        Debug "A new Object of class myObject was just created"
    EndProcedure
EndClass
Are you saying, this is not possible with other pre-compilers?
Foz
Addict
Addict
Posts: 1359
Joined: Tue Nov 13, 2007 12:42 pm
Location: Manchester, UK

Re: OOP Support (it is time)

Post by Foz »

No, you declare the procedure in the class, but then write it outside of the class. A very bizarre method from my point of view compared to the way I'm used to doing classes, but there you go.

I think the Declaration method though is very close to the "raw" way of doing things, (interface, structure, procedures, data section)
User avatar
TomS
Enthusiast
Enthusiast
Posts: 342
Joined: Sun Mar 18, 2007 2:26 pm
Location: Munich, Germany

Re: OOP Support (it is time)

Post by TomS »

Foz wrote:I think the Declaration method though is very close to the "raw" way of doing things, (interface, structure, procedures, data section)
Maybe so. But then I'm glad I use SimpleOOP.
I have to adapt to the small changes in syntax when I come from coding in php, but at least it's generally the same style.
If it's the same in VB then I'm guessing that's kinda the accepted standard and the other pre-compilers fall out of line, because the authors thought PB couldn't handle it, or they themself, of they just didn't want to stray too far away from the pb syntax.

Anyway. Because of this I recommend SimpleOOP over the others to you, c4s ;)

It's also very much like the Feature Request "Procedures inside Structures".
Only that instead of a structure you have a class (in the end it's still a structure with a prototype, ofcourse)

Feature requested in the other thread

Code: Select all

Structure myStructure
	int.i
	string.s
	
	Procedure test()
		Debug string
	EndProcedure 
	
EndStructure 

Define var.myStructure
var\string = "Hello World"
var\test() ;Hello World
Actual Code with SimpleOOP

Code: Select all

Class MyClass
   Public string.s ;Not sure whether public or define, doing this without simple oop right now.
   
   Public Method test()
      Debug This\string
   EndMethod
   
EndClass

*Obj.MyClass = NewObject
*Obj\string = "Hello World"
*Obj\test() ;Hello World
Ofcourse normally the variable shouldn't be public. But this immitates the non-working code perfectly. And it works perfectly.
Marlin
Enthusiast
Enthusiast
Posts: 406
Joined: Sun Sep 17, 2006 1:24 pm
Location: Germany

Re: OOP Support (it is time)

Post by Marlin »

Foz wrote:No, you declare the procedure in the class, but then write it outside of the class.
Doesn't that mean, you must watch the names of your procedures?

F.e. can you have a procedure "set" in more than one class under those circumstances?

If you need to fix that using "naming conventions", I do not see the point in using classes at all.
Foz wrote:A very bizarre method from my point of view compared to the way I'm used to doing classes
I certainly agree with that. ;-)

OOP supposed to make things simpler, not bloat your code and make you write the same thing twice,
with no real tangible advantage.
If liberty means anything at all, it means the right to tell people what they do not want to hear.
- George Orwell
DaylightDreamer
User
User
Posts: 52
Joined: Wed Feb 04, 2009 8:11 am
Location: Armenia

Re: OOP Support (it is time)

Post by DaylightDreamer »

I think i gonna give try to SimpleOOP with heavy object operations.
And i will put here the results.
DaylightDreamer
User
User
Posts: 52
Joined: Wed Feb 04, 2009 8:11 am
Location: Armenia

Re: OOP Support (it is time)

Post by DaylightDreamer »

Hm..
Can someone give me the link to SimpleOOP precompiler. ?
c4s
Addict
Addict
Posts: 1981
Joined: Thu Nov 01, 2007 5:37 pm
Location: Germany

Re: OOP Support (it is time)

Post by c4s »

@TomS
Thank you for the tip. I'll give SimpleOOP a try soon.


@DaylightDreamer
Here is the german thread (translated by Bing ;)): http://www.microsofttranslator.com/bv.a ... php?t=5915
Download (There also is an english manual in the download archive): https://www.dropbox.com/s/oo85ru13fidb7zr/SimpleOOP
If any of you native English speakers have any suggestions for the above text, please let me know (via PM). Thanks!
DaylightDreamer
User
User
Posts: 52
Joined: Wed Feb 04, 2009 8:11 am
Location: Armenia

Re: OOP Support (it is time)

Post by DaylightDreamer »

Thank you :)
User avatar
Fluid Byte
Addict
Addict
Posts: 2336
Joined: Fri Jul 21, 2006 4:41 am
Location: Berlin, Germany

Re: OOP Support (it is time)

Post by Fluid Byte »

What the hell?!
DaylightDreamer wrote:I'm not speaking about pre compilers or some attempts to emulate it ....
DaylightDreamer wrote:I think i gonna give try to SimpleOOP with heavy object operations.
Dude, make up your mind or let it go already ....
Windows 10 Pro, 64-Bit / Whose Hoff is it anyway?
PMV
Enthusiast
Enthusiast
Posts: 727
Joined: Sat Feb 24, 2007 3:15 pm
Location: Germany

Re: OOP Support (it is time)

Post by PMV »

Fluid Byte wrote:What the hell?!
DaylightDreamer wrote:I'm not speaking about pre compilers or some attempts to emulate it ....
DaylightDreamer wrote:I think i gonna give try to SimpleOOP with heavy object operations.
Dude, make up your mind or let it go already ....
Why isn't it allowed to change an opinion after a month of
discussion? :shock:
Ah yes ... you are a kind of man who would never change
it, no matter what comes :lol:
VICTOR
New User
New User
Posts: 3
Joined: Sat Feb 26, 2011 7:03 pm
Location: MADRID

Re: OOP Support (it is time)

Post by VICTOR »

Hi!

I'm a newbie in Purebasic and I'm testing SimpleOOP. Compiler shows an error "Invalid memory access. (read error at address 0)" with a simple example:

Code: Select all

EnableExplicit

Class MiClase
  Public Variable.l
EndClass

Define *MiObjeto.MiClase

*MiObjeto = NewObject.MiClase
*MiObjeto\Variable = 123
Debug *MiObjeto\Variable
But, if I include a string or an array in class declaration, it works.

Code: Select all

EnableExplicit

Class MiClase
  Public Variable.l
  Public Cadena$
EndClass

Define *MiObjeto.MiClase

*MiObjeto = NewObject.MiClase
*MiObjeto\Variable = 123
Debug *MiObjeto\Variable
Why? I'm confused :(


Cheers!

VICTOR
User avatar
TomS
Enthusiast
Enthusiast
Posts: 342
Joined: Sun Mar 18, 2007 2:26 pm
Location: Munich, Germany

Re: OOP Support (it is time)

Post by TomS »

The first code works like a charm.
In which line does the error occur?
VICTOR
New User
New User
Posts: 3
Joined: Sat Feb 26, 2011 7:03 pm
Location: MADRID

Re: OOP Support (it is time)

Post by VICTOR »

TomS wrote:The first code works like a charm.
In which line does the error occur?
It fails in:

*MiObjeto = NewObject.MiClase

I'm using Windows 7 (x64). Tomorrow I'll test it in XP 32 bits...
VICTOR
New User
New User
Posts: 3
Joined: Sat Feb 26, 2011 7:03 pm
Location: MADRID

Re: OOP Support (it is time)

Post by VICTOR »

I've just test first code in other computer (XP Pro SP3 x86) and it works... :shock:

Why this code cracks in Windows 7 64 bits? maybe a bug? a bad installation? a wrong compiler option? a clumsy guy at a computer? :oops:


Cheers,

VICTOR
User avatar
utopiomania
Addict
Addict
Posts: 1655
Joined: Tue May 10, 2005 10:00 pm
Location: Norway

Re: OOP Support (it is time)

Post by utopiomania »

In my opinion, a simple to use and straightforward OO version could be marketed as an
alternative to the current event loop based version, like PB Classic/PB Objects..

I would certainly register the last one, and continue to use both versions.
Locked