Page 10 of 22
Re: Blog post !
Posted: Wed Mar 17, 2021 3:30 am
by Rinzwind
Extending structs with 'easy to use function pointers with auto-self-reference' also provide an alternative to the Module thing and you'll get multiple instancing capability for free... The Module, as is, is kind of lacking anyway in regard to scope handling (compared to same idea in Pascal (Unit)).
Re: Blog post !
Posted: Wed Mar 17, 2021 7:11 am
by Danilo
StarBootics wrote:This reminds me what Guimauve's Dev-Type program was generating back then. It's nothing new in town and to be honest I can't consider this OOP.
We are not really talking about OOP. OOP with Classes, Methods, etc. was discussed 10 or 15 years ago and
the result was it will not be supported by PureBasic. It is a waste of time to discuss this over and over again.
Maybe the PureBasic language is already considered finished, I don't know. If not, we can talk about
new ideas.
That's why I was bringing Rust into the discussion: Rust has no classes, but it has some features that combine
data structures and functions that work with that data structures:
Something simple like Procedures for Data Structures could probably fit nicely into PureBasic's procedural approach. But that's just my opinion.
Code: Select all
Structure Rectangle
width.i
height.i
EndStructure
Procedure.i Area() For Rectangle
ProcedureReturn Self\width * Self\height
EndProcedure
Define rect.Rectangle
rect\width = 30
rect\height = 50
Print("the area of the rectangle is " + rect\Area() + " square pixels.")
All it needs is a keyword like
Self,
This, or
Me to access the data structure.
Internally Self is just a pointer to the data structure type. In the example above it would be *Self.Rectangle (internal to the compiler only).
A call of a Data Structure Procedure would look like this inside the compiler:
Code: Select all
Define rect.Rectangle ; Inside compiler:
;
Debug rect\Area() ; Debug Area( @rect ) ; internal name: __procedure35
;
Define *r.Rectangle = AllocateMemory( SizeOf(Rectangle) ) ;
;
Debug *r\Area() ; Debug Area( *r ) ; internal name: __procedure35
Not fancy OOP with encapsulation etc., because the makers of PureBasic don't want that. But it would bind Procedures to Data Structures in a very simple manner.

The advantage is that everybody can just write new Procedures for existing data structures and add more and more functionality - just by writing simple, additional procedures in the usual PureBasic style.
Re: Blog post !
Posted: Wed Mar 17, 2021 8:45 am
by sq4
Danilo wrote:We are not really talking about OOP. OOP with Classes, Methods, etc. was discussed 10 or 15 years ago and
the result was it will not be supported by PureBasic. It is a waste of time to discuss this over and over again.
I agree!
PB is 100% procedural and this new transpiler is just a step into reaching more CPU architectures.
I just hope that inline asm will be continued. (albeit just for the sake of legacy code)
Exciting times!
Re: Blog post !
Posted: Wed Mar 17, 2021 8:57 am
by Keya
sq4 wrote:I just hope that inline asm will be continued. (albeit just for the sake of legacy code)
Exciting times!
Fred said "- Inline ASM won't be supported directly at start. We plan to add naked ProcedureASM : EndProdecure which will create an assembly file, use fasm and link it to the final exe without needed to do anything"
That sounds awesome to me because it means existing PB-asm code should mostly still be compatible.
gcc (the C compiler PB will be using) also supports its own form of inline asm, but it's a bit
quirky!
Re: Blog post !
Posted: Wed Mar 17, 2021 9:06 am
by Rinzwind
Danilo +1

Re: Blog post !
Posted: Wed Mar 17, 2021 11:04 am
by the.weavster
Danilo wrote:Something simple like Procedures for Data Structures could probably fit nicely into PureBasic's procedural approach. But that's just my opinion.
Code: Select all
Structure Rectangle
width.i
height.i
EndStructure
Procedure.i Area() For Rectangle
ProcedureReturn Self\width * Self\height
EndProcedure
Define rect.Rectangle
rect\width = 30
rect\height = 50
Print("the area of the rectangle is " + rect\Area() + " square pixels.")
Very nice indeed
And similar to how
Nim works which is another language that translates to C.
Re: Blog post !
Posted: Wed Mar 17, 2021 11:57 am
by StarBootics
Hello everyone,
I only hope that a hack like this will still be possible :
Code: Select all
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; AUTOMATICALLY GENERATED CODE, DO NOT MODIFY
; UNLESS YOU REALLY, REALLY, REALLY MEAN IT !!
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; Code generated by : Dev-Object - V1.4.3
; Project name : the project name here
; File name : File name here
; File Version : 0.0.0
; Programmation : In progress
; Programmed by : StarBootics
; Creation Date : 17-03-2021
; Last update : 17-03-2021
; Coded for PureBasic : V5.73 LTS
; Platform : Windows, Linux, MacOS X
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
DeclareModule Car
Interface Car
GetName.s()
GetSpeed.d()
GetFuel.d()
SetName(P_Name.s)
SetSpeed(P_Speed.d)
SetFuel(P_Fuel.d)
Free()
EndInterface
; Declare Free(*This)
Declare.i New(P_Name.s = "", P_Speed.d = 0.0, P_Fuel.d = 0.0)
EndDeclareModule
Module Car
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< Structure declaration <<<<<
Structure Private_Members
VirtualTable.i
Name.s
Speed.d
Fuel.d
EndStructure
; <<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< The observators <<<<<
Procedure.s GetName(*This.Private_Members)
ProcedureReturn *This\Name
EndProcedure
Procedure.d GetSpeed(*This.Private_Members)
ProcedureReturn *This\Speed
EndProcedure
Procedure.d GetFuel(*This.Private_Members)
ProcedureReturn *This\Fuel
EndProcedure
; <<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< The mutators <<<<<
Procedure SetName(*This.Private_Members, P_Name.s)
*This\Name = P_Name
EndProcedure
Procedure SetSpeed(*This.Private_Members, P_Speed.d)
*This\Speed = P_Speed
EndProcedure
Procedure SetFuel(*This.Private_Members, P_Fuel.d)
*This\Fuel = P_Fuel
EndProcedure
; <<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< The Destructor <<<<<
Procedure Free(*This.Private_Members)
FreeStructure(*This)
EndProcedure
; <<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< The Constructor <<<<<
Procedure.i New(P_Name.s = "", P_Speed.d = 0.0, P_Fuel.d = 0.0)
*This.Private_Members = AllocateStructure(Private_Members)
*This\VirtualTable = ?START_METHODS
*This\Name = P_Name
*This\Speed = P_Speed
*This\Fuel = P_Fuel
ProcedureReturn *This
EndProcedure
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< The Virtual Table Entries <<<<<
DataSection
START_METHODS:
Data.i @GetName()
Data.i @GetSpeed()
Data.i @GetFuel()
Data.i @SetName()
Data.i @SetSpeed()
Data.i @SetFuel()
Data.i @Free()
END_METHODS:
EndDataSection
EndModule
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< Code generated in : 00.001 seconds (131000.00 lines/second) <<<<<
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<<<<<<<<<<<<<<<<<<<<
; <<<<< END OF FILE <<<<<
; <<<<<<<<<<<<<<<<<<<<<<<
That out of the way, I have another question for Fred : Will all standard C language types be available, especially unsigned long ?
Best regards
StarBootics
Re: Blog post !
Posted: Wed Mar 17, 2021 3:23 pm
by Keya
btw, I hope Fred changes the software title to something new, and charges us some money for it!$ (because it is literally a brand new software project)
I'm getting tired of feeling guilty for all these free software updates from Fred

He's got a family to feed and its incredible how much work he's done for us over the DECADES _at no expense to us_
PLEASE Fred, we want to pay for your BRILLIANT WORK!!!!!!!!! because without your brilliant work, many of us wouldn't have been able to find our own niches

And we want to _SUPPORT_ PB!!! SHUT UP AND TAKE OUR MONEY!!!

♥
Re: Blog post !
Posted: Wed Mar 17, 2021 3:34 pm
by BarryG
I agree with Keya. The new version should be PureBasic v6.00 and come with a new license model. Fred could "grandfather" existing paid customers if he prefers (ie. not charge us) but make all new buyers have a renewal fee every year. It makes better business sense.
Re: Blog post !
Posted: Wed Mar 17, 2021 3:38 pm
by User_Russian
Keya wrote:I'm getting tired of feeling guilty for all these free software updates from Fred
Especially for you and others who getting tired of feeling guilty.

Why aren't you sending donations to Fred?
Re: Blog post !
Posted: Wed Mar 17, 2021 3:45 pm
by Keya
User_Russian: yes but that's just voluntary, so most people won't

Re: Blog post !
Posted: Wed Mar 17, 2021 4:39 pm
by jacdelad
I'm doing my part![img]
https://uploads.tapatalk-cdn.com/202103 ... 7215d0.jpg[/img]
Edit: Ah crap, it should be animated...
Re: Blog post !
Posted: Wed Mar 17, 2021 5:04 pm
by Mijikai
ProcedureASM() was one of my feature requests it would be really cool if its still an option once/if inline is back.
Re: Blog post !
Posted: Thu Mar 18, 2021 12:40 pm
by DK_PETER
User_Russian wrote:Keya wrote:I'm getting tired of feeling guilty for all these free software updates from Fred
Especially for you and others who getting tired of feeling guilty.

Why aren't you sending donations to Fred?
I'm not 'walking on clouds' like some other people here but I'm certainly looking forward to each new update..
But user_Russian is correct - it is time to make another donation. Not because of future updates but because it is time. [donation made].
Stay strong and creative Fred & team!

Re: Blog post !
Posted: Thu Mar 18, 2021 4:51 pm
by Fred
Danilo wrote:Code: Select all
Structure Rectangle
width.i
height.i
EndStructure
Procedure.i Area() For Rectangle
ProcedureReturn Self\width * Self\height
EndProcedure
Define rect.Rectangle
rect\width = 30
rect\height = 50
Print("the area of the rectangle is " + rect\Area() + " square pixels.")
I actually like this way, very clever.