Easy object oriented programming (just look at my example)

Got an idea for enhancing PureBasic? New command(s) you'd like to see?

Was this a good idea?

Yes.
50
56%
No.
19
21%
Maybe.
20
22%
 
Total votes: 89

Dare2
Moderator
Moderator
Posts: 3321
Joined: Sat Dec 27, 2003 3:55 am
Location: Great Southern Land

Post by Dare2 »

Hi Kukulkan,

I DLed that a little while ago, looked through the code and at the powerpoint presentation. Haven't spent much time with it, or tried to translate to English, as OO is not really big thing for me (perhaps "yet"). :)

But it looks, um, classy.

Perhaps Fred should make it official. Then everyone will take note. (Just kidding) :)
@}--`--,-- A rose by any other name ..
josku_x
Addict
Addict
Posts: 997
Joined: Sat Sep 24, 2005 2:08 pm

Post by josku_x »

A yes from me.

I think PureBasic is NOT a BASIC language. Sure it supports all BASIC keywords and is implemented as a BASIC language, but it isn't.

I have been using PowerBasic and the syntax is slighlty different than Purebasic's. I don't mean Purebasic is bad, nor do I mean I hate BASIC or that BASIC sucks.

I mean, what if Purebasic would be it's own language still supporting the BASIC keywords and have it's own cool functions?

I think more people would buy it if they would know how powerful it is.

so, I think that object oriented programming would be a great idea.

*unless that I'll just work with GameMaker :wink: *
User avatar
fsw
Addict
Addict
Posts: 1603
Joined: Tue Apr 29, 2003 9:18 pm
Location: North by Northwest

Post by fsw »

Kukulkan wrote:I tell you again: There is already such a preprocessor available:

Go to http://members.chello.at/pure-basic-essentials/ and select "Downloads" and "Dokumente". On "Downloads" you can see a sample-code of accepted oo-code.

Kukulkan
Too bad their own example on the download page doesn't work :shock:

Code: Select all

Class MyClass1
	attribute1.l
	
	Method setAttribute1(value.l)
		*this\attribute1 = value
	EndMethod
	
	Method.l getAttribute1()
		MethodReturn *this\attribute1
	EndMethod
EndClass

Class MyClass2 Extends MyClass1
	attribute2.l
	
	Method setAttribute2(value.l)
		*this\attribute2 = value
	EndMethod
	
	Method.l getAttribute2()
		MethodReturn *this\attribute2
	EndMethod
EndClass

NewObject *obj.MyClass2

*obj\setAttribute1(1)
*obj\setAttribute2(2)
Debug Str(*obj\getAttribute1()) + " / " + Str(*obj\getAttribute2())
*obj\destruct()

End 
My take:
First the preprocessor has to work 100%, and then you can go the next mile and code a special editor for it or whatever is needed.

In my opinion they do to much at once ...

It would have been great - if it would work :wink:
User avatar
Kukulkan
Addict
Addict
Posts: 1396
Joined: Mon Jun 06, 2005 2:35 pm
Location: germany
Contact:

Post by Kukulkan »

Hi fsw,
Too bad their own example on the download page doesn't work
Why do you tell something? :shock:

I tested it in this moment and it works perfectly!!! :!:

Simply
- download the executable
- run it
- select the desired OOP-Code (like exactly the example in your post)
- watch the resulting file (*_pp.pb extended filename)

The generated code compiles without any errors and gives the correct results!

Whats your problem????? :?:

Kukulkan
User avatar
fsw
Addict
Addict
Posts: 1603
Joined: Tue Apr 29, 2003 9:18 pm
Location: North by Northwest

Post by fsw »

Kukulkan wrote:Hi fsw,
Too bad their own example on the download page doesn't work
Why do you tell something? :shock:
Because it doesn't compile here.
Kukulkan wrote: I tested it in this moment and it works perfectly!!! :!:
Good for you :wink:
Kukulkan wrote: Simply
- download the executable
- run it
- select the desired OOP-Code (like exactly the example in your post)
- watch the resulting file (*_pp.pb extended filename)

The generated code compiles without any errors and gives the correct results!
That's what I did, and the resulting file has a size of 0 bytes.
Kukulkan wrote: Whats your problem????? :?:
Kukulkan
There is a reported error.
I'm not @ home so I can't tell you in which line the error was reported.
If I have time tonight I will rerun it again and post the error message.
User avatar
fsw
Addict
Addict
Posts: 1603
Joined: Tue Apr 29, 2003 9:18 pm
Location: North by Northwest

Post by fsw »

OK,
used PBE-ClassPreCompiler.exe (size 25600 bytes) with original file
I've copyed and pasted from the essential downloadpage.

Get the error:
"Row 20: Global code not allowed in a class-syntaxerror!"

For the next test I've copyed and pasted from my post above.
and get the message:
"No errors!"

Strange...

Looked through both code files and they look the same,except the file that doesn't work has TAB's in it instead of SPACES.

Now I killed all TAB's in the original file and it works now.


Conclusion:
There is a BUG when TAB's are used.
dagcrack
Addict
Addict
Posts: 1868
Joined: Sun Mar 07, 2004 8:47 am
Location: Argentina
Contact:

Post by dagcrack »

I say its good and only good if you can still programm in PB with out having to use it. that said, maybe it's good for many people, maybe its not. but if its there and its optional, it wont harm those who wouldnt use it (or will, eventually).
! Black holes are where God divided by zero !
My little blog!
(Not for the faint hearted!)
rsts
Addict
Addict
Posts: 2736
Joined: Wed Aug 24, 2005 8:39 am
Location: Southwest OH - USA

Post by rsts »

I'm from the "old school" (procedural) and while I wouldn't really care if OO were included (as long as I didn't have to use it and it didn't impact my code in any way), I can't imagine that it wouldn't take resources away from the development of other, more pertinant, features I would use and benefit from.

So, as long as the name of the game is "Fred", and the name of the product is PureBasic, I'd prefer we stick with "Pure Basic" not OBasic or BasicO or whatever.

cheers
User avatar
Kukulkan
Addict
Addict
Posts: 1396
Joined: Mon Jun 06, 2005 2:35 pm
Location: germany
Contact:

Post by Kukulkan »

Hi fsw,

Thank you for the tests with the precompiler. I will tell it to didelphodon on the PBE-forum so he can fix it. I used jaPBe. Seems that jaPBe converts every TAB to spaces. So I didn't found this bug. This will be easy to remove.

Kukulkan
User avatar
fsw
Addict
Addict
Posts: 1603
Joined: Tue Apr 29, 2003 9:18 pm
Location: North by Northwest

Post by fsw »

8)
Post Reply