Blog post !

Developed or developing a new product in PureBasic? Tell the world about it.
Rinzwind
Enthusiast
Enthusiast
Posts: 679
Joined: Wed Mar 11, 2009 4:06 pm
Location: NL

Re: Blog post !

Post 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)).
User avatar
Danilo
Addict
Addict
Posts: 3036
Joined: Sat Apr 26, 2003 8:26 am
Location: Planet Earth

Re: Blog post !

Post 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.
sq4
User
User
Posts: 98
Joined: Wed Feb 26, 2014 3:16 pm
Contact:

Re: Blog post !

Post 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!
User avatar
Keya
Addict
Addict
Posts: 1890
Joined: Thu Jun 04, 2015 7:10 am

Re: Blog post !

Post 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!
Rinzwind
Enthusiast
Enthusiast
Posts: 679
Joined: Wed Mar 11, 2009 4:06 pm
Location: NL

Re: Blog post !

Post by Rinzwind »

Danilo +1
:idea:
User avatar
the.weavster
Addict
Addict
Posts: 1576
Joined: Thu Jul 03, 2003 6:53 pm
Location: England

Re: Blog post !

Post 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.
User avatar
StarBootics
Addict
Addict
Posts: 1006
Joined: Sun Jul 07, 2013 11:35 am
Location: Canada

Re: Blog post !

Post 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
The Stone Age did not end due to a shortage of stones !
User avatar
Keya
Addict
Addict
Posts: 1890
Joined: Thu Jun 04, 2015 7:10 am

Re: Blog post !

Post 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!!! :) :)
BarryG
Addict
Addict
Posts: 4128
Joined: Thu Apr 18, 2019 8:17 am

Re: Blog post !

Post 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.
User_Russian
Addict
Addict
Posts: 1519
Joined: Wed Nov 12, 2008 5:01 pm
Location: Russia

Re: Blog post !

Post 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.
Image
Why aren't you sending donations to Fred?
User avatar
Keya
Addict
Addict
Posts: 1890
Joined: Thu Jun 04, 2015 7:10 am

Re: Blog post !

Post by Keya »

User_Russian: yes but that's just voluntary, so most people won't :(
User avatar
jacdelad
Addict
Addict
Posts: 1993
Joined: Wed Feb 03, 2021 12:46 pm
Location: Riesa

Re: Blog post !

Post by jacdelad »

I'm doing my part![img]https://uploads.tapatalk-cdn.com/202103 ... 7215d0.jpg[/img]

Edit: Ah crap, it should be animated...
Good morning, that's a nice tnetennba!

PureBasic 6.21/Windows 11 x64/Ryzen 7900X/32GB RAM/3TB SSD
Synology DS1821+/DX517, 130.9TB+50.8TB+2TB SSD
User avatar
Mijikai
Addict
Addict
Posts: 1517
Joined: Sun Sep 11, 2016 2:17 pm

Re: Blog post !

Post by Mijikai »

ProcedureASM() was one of my feature requests it would be really cool if its still an option once/if inline is back.
User avatar
DK_PETER
Addict
Addict
Posts: 904
Joined: Sat Feb 19, 2011 10:06 am
Location: Denmark
Contact:

Re: Blog post !

Post 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.
Image
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! :-)
Current configurations:
Ubuntu 20.04/64 bit - Window 10 64 bit
Intel 6800K, GeForce Gtx 1060, 32 gb ram.
Amd Ryzen 9 5950X, GeForce 3070, 128 gb ram.
Fred
Administrator
Administrator
Posts: 18162
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: Blog post !

Post 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.
Post Reply