Code: Select all
Interface SomeObject
EndInterface
obj.SomeObject=0
I know that objects are less than second-class in PureBasic and object-oriented programming is not supported. But this is a very minor feature that will go a long way for veterans looking to push this language to the very edge. I would love to use PureBasic more but I continue to find it difficult to port code to PureBasic, which limits its exposure in my work.
Here is a specific example of what I would like to be able to do:
Code: Select all
Interface BoxObject
getWidth()
EndInterface
Interface SomeObject
; [Error] A structure can't be used with ProcedureReturn.
getBox.BoxObject()
EndInterface
obj.SomeObject= ...
Debug obj\getBox()\getWidth()
We can already assign references to objects:
Code: Select all
obj.SomeObject=*instance
Code: Select all
Procedure.SomeObject ProcA()
; [Error] A structure can't be used with ProcedureReturn.
ProcedureReturn *instance
EndProcedure
Code: Select all
Procedure SayHello()
Debug "Hello!"
EndProcedure
Prototype.i ProtoSayHello()
Structure VTable
SayHello.ProtoSayHello
EndStructure
a.VTable
a\SayHello=@SayHello()
; Works fine
a\SayHello()