I have a request for a future update to PureBasic.
I use both PureBasic, and GLBasic, each for different types of projects.
The most recent major update to GLBasic is a feature I have come to like very much.
It now allows Functions inside of Types.
This allows for a (sort of) OOP approach to organizing code, without added complexity.
I find it allows me to make nice, self contained little code objects, which are very suited to re-usability, and still think and write in a procedural way.
Would it be possible to add such a feature to PureBasic.
I know, OOP is entirely possible with Prototypes, Interfaces, Function Pointers, etc.
This proposed method though, while definitely not adhering to all the concepts of OOP, it borrows just enough to be useful, while not becoming cumbersome for amateurs such as myself.
Here is how such an implementation may look (borrowed directly from the new version of GLBasic, but adapted to PureBasic syntax).
Code: Select all
Structure foobar
; Members
x.i
y.i
; Methods
Procedure.i bar(z.i)
result.i = (self\x + self\y) * z
ProcedureReturn result
EndProcedure
Procedure set(x.i, y.i)
self\x = x
self\y = y
EndProcedure
EndStructure
Dim foo.foobar(1)
foo(0)\set(10, 20)
result.i = foo(0)\bar(30)
I would be very pleased though of course if it is deemed a good idea, and implemented.
Thanks in advance.
Dave