Hi Petr,
Yes I will canonise new and del (and constructor and destructor) so they become part of the core language. The "hard-cores" will still be able to create objects to their own specification but these are a safe way to create dynamic objects.
Example:
'==========
class shape
'==========
'
double x,y,z
'
method constructor(double*a,double*b,double*c)
'=============================================
x=a : y=b : z=c
string tab=chr 9
print "construct" tab x tab y tab z
end method
method destructor()
'==================
print "destroy"
end method
end class
new shape cuboid 1,2,3
'...
del cuboid
Here are the entries in keyw.bas where most O2 keywords are defined:
data "new" ,-19,"%1 * %2 : & %2=news sizeof %1 : %2.constructor"
'=====================
'action: create a dynamic object and call its constructor method.
'use: to create and initialise persistent objects
'example: new shape cuboid 1,1,1
'related: del
'group: system macro
data "del" ,-19,"%1.destructor : frees & %1 : & %1=0"
'=====================
'action: Call a dynamic object's destructor method and disallocate its memorey block.
'use: to delete persistent objects
'example: del cuboid
'related: new
'group: system macro
I'll put this into Alpha024 which I will release before Christmas.
Many thanks!
Charles