suicidal object

Posted by Marian Edu on 19-May-2014 13:05

did anyone else tried to delete this-object before? seems to work, but checking if this is the expected behaviour?

All Replies

Posted by jmls on 19-May-2014 13:07

I've used it before. Works, but not sure about the use case, except for to trigger a destructor ..  ;)


[collapse]
On 19 May 2014 19:06, Marian Edu <bounce-medu@community.progress.com> wrote:
Thread created by Marian Edu

did 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.




--
Julian Lyndon-Smith
IT Director,
dot.r
http://www.dotr.com

"The bitterness of poor quality remains long after the sweetness of low price is forgotten”

Follow dot.r on http://twitter.com/DotRlimited
[/collapse]

Posted by Mike Fechner on 19-May-2014 13:11

Works fine. And gone is gone.


Am 19.05.2014 um 20:06 schrieb "Marian Edu" <bounce-medu@community.progress.com>:

Thread created by Marian Edu

did 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.

Posted by Thomas Mercer-Hursh on 19-May-2014 13:12

Why not?

Posted by Marian Edu on 20-May-2014 00:39

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).

Posted by Lieven De Foor on 23-May-2014 05:06

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).

This thread is closed