| Attentive viewers will know that I found a reason to buy Max, but I'd be lying if I said that my familiarity with OOP was it. The fact that we don't manually delete/free things any more (releasing integer assignments aside) is making me a bit apprehensive. So please consider this... 
 
 
SuperStrict
Type myType
	Field x:Int
	Field y:Int
	
	Function create(initX:Int,initY:Int)
		Local newMyType:myType = New myType
		newMyType.x=initX
		newMyType.y=initY
		ListAddLast (myTypeList,newMyType)
	End Function
	
	Method destroy()
		ListRemove(myTypeList,Self) 
	End Method
EndType
Global myTypeList:TList = CreateList()
'=========================================
For Local i:Int = 0 To 10
	myType.create(10,20*i)
	Global unListed:myType=New myType
Next
 
 ...and tell me do:
 
 (1)Ignoring the 'Global unListed' line (which I'll ask you about in a minute), does this generally hang together as a reasonably solid way to handle object creation and destruction in Max?
 
 (2)Thinking of garbage collection, in order to create and destroy instances there has to be a reference to that instance made in the associated method/function. Does this mean that the last instance created/destroyed will hang about in memory even when it has been removed from its list? Should I be worrying about this or does it all really just take care of itself as long as there is nothing to release?
 
 (3)Looking specifically at that 'Global unListed' line -- does the garbage collector cope with the fact that the previous reference is redundant as the for/next loop iterates, or is this a really dumb thing to do? I'm just curious really because I noticed that going...
 
 
Global unListed:myType=New myType
Global unListed:myType=New myType
 ...makes the compiler squawk whereas B3D would just accept it (presumably trusting you to deallocate the first object before initialising the second).
 
 
 EDIT:Took out my debug code.
 
 
 |