did anyone else tried to delete this-object before? seems to work, but checking if this is the expected behaviour?
Thread created by Marian Edudid anyone else tried to delete this-object before? seems to work, but checking if this is the expected behaviour?
Stop receiving emails on this subject.Flag this post as spam/abuse.
Thread created by Marian Edudid anyone else tried to delete this-object before? seems to work, but checking if this is the expected behaviour?
Stop receiving emails on this subject.Flag this post as spam/abuse.
Why not?
sure thing, even with GC I still like to clean-up the mess behind :)
The use case is just the plain builder pattern, in my particular case a http request builder like this:
httpReq = HttpRequestBuilder:postRequest('url'):withBasicAuth('usr', 'pass'):withBody(reqData):build().
HttpRequestBuilder have a private constructor and one instance will hold building parts during build process but once the build method is called there is no need for that builder instance so `delete this-object` seemed appropriate (although odd for some reason I can't really explain).
Please be aware that as long as the object is still in the stack, deleting is deferred until that method returns (same behaviour with persistent procedures).
You can still reference methods/variables and even call it from outside as long as the call to the method that's deleting the object is still in the stack.
I've logged a bug with technical support though because of an inconsistency with the VALID-OBJECT/VALID-HANDLE return value after the DELETE has been performed (in short, VALID-OBJECT returns false while the object is still alive, VALID-HANDLE for persistent procedures works correctly).