Hi!
I noticed that "Object Ptr" isn't a correct BlitzMax variable data type.
But why?
It could be simply defined as a pointer to a variable of type "Object". That means a pointer to a pointer to a BBObject struct or (in C) "typedef BBObject** bbObjectPtrType". (BBObject defined in "mod/brl.mod/blitz.mod/blitz_object.h")
I thought this data type was allowed in any version before; but why isn't it allowed still?
Because the GC behaviour has changed?
I think if everyone is using this type carefully there will be no problems when using "Object Ptr" data type with the GC.
Here's an example which would run correctly with the GC if "Object Ptr" data type would be allowed:
So please, if anyone knows, tell me why is this type not allowed in this version; and: will it be re-allowed in any future version?
I noticed that "Object Ptr" isn't a correct BlitzMax variable data type.
But why?
It could be simply defined as a pointer to a variable of type "Object". That means a pointer to a pointer to a BBObject struct or (in C) "typedef BBObject** bbObjectPtrType". (BBObject defined in "mod/brl.mod/blitz.mod/blitz_object.h")
I thought this data type was allowed in any version before; but why isn't it allowed still?
Because the GC behaviour has changed?
I think if everyone is using this type carefully there will be no problems when using "Object Ptr" data type with the GC.
Here's an example which would run correctly with the GC if "Object Ptr" data type would be allowed:
Strict Framework brl.blitz Local O:Object = New T'creates a new object, blitzmax GC cares about the object referenced by O Local P:Object Ptr = Varptr O'get the address of the variable in memory, the GC doesn't care about variables of type "? Ptr" DoAnything P'call a function; while this function is executed the variable O is still in scope and the object has at least 1 reference 'now the function has ended; but the object's reference counter still counts 1 reference: the main programme's variable O 'Go on with the main programme;the object can still be accessed by O and P[0] P = Null 'now the object can only be accessed by O; but the reference counter stays at the prev. value (1 reference: O) O = Null'this causes the objects reference counter to decrement: so there's no reference and the object will be deleted soon 'Go on with the code Function DoAnything ( P:Object Ptr ) Local O:Object = P [ 0 ]'set a new variable O to this object; now it has 2 references: the main programme's O and the sub programme's O 'Do anything with the object; all the time this code runs the object has at least these 2 references EndFunction'now the function ends; this causes the sub programme's variable O to run out of scope, so the object's reference counter decrements Type T EndType
So please, if anyone knows, tell me why is this type not allowed in this version; and: will it be re-allowed in any future version?