self = null fails
BlitzMax Forums/BlitzMax Programming/self = null fails
| ||
hmm, why can't I do this:Type TMyType Method Kill() 'clear some stuff then kill the pointer to this type Self = Null End Method End Type I guess I'm supposed to either: a) Make Kill a function that I pass in a pointer to TMyType as a var and then set the pointer to null OR b) just call test.Kill() and then test = null where test is an instance of TMyType? Thanks for any help. Maybe I don't even need to worry about it due to GC... |
| ||
I stick this function within the TypeFunction Free(d:DirtyRect) DirtyRectList.Remove d d = Null End Function Not even sure If I need to though. |
| ||
yeah that's kind what I was thinking of (the function) and not sure if I need it. In fact the type I've made does have a list that that needs something removing from it, so that's a very similar example. |
| ||
I don't think your original code would work Grey just because you're asking it to exist long enough to write Null into itself, and yet at the same time not exist. It's impossible. |
| ||
I can see your logic Angel, but surly the object exists utill flow leaves the method? Or does it? |
| ||
@Grey- Think of self as a function that returns a reference to the object the method was invoked from. It can't be set to null - its any external references in your code to that object that need to be nulled. So yeah a) would work I guess. @Indiepath - I don't think you need d=Null in that function - d is a local that goes out of scope anyway when the function exits. If d was 'var' it may be useful. |
| ||
Angel: Yeah that's what I figured. Nomen: Thanks. Yeah I suggested in a) that the passed in var should be a "var" so it can be nulled properly. |