NEW as a parameter

Posted by Tim Kuehn on 18-Jan-2008 12:36

By the way, I think it would be desirable to be able to pass a new object instance to a function/procedure/method call: xobjRef:SomeMethod(NEW someotherclass()). And yes, I know, that this makes it harder for the caller to control the lifetime of the new instance without having a handle.

This is getting afield of the "handle:find-first" discussion in another thread, so I'm starting another one.

What is the use case for

run procedure-name(new object-class(constructor sig list))

and how does C++ deal with managing the resulting object instance's lifetime? Is this considered part of the "garbage collection" in that language?

All Replies

Posted by Shelley Chase on 18-Jan-2008 14:59

Hi Tim,

The NEW function is available in 10.1B and beyond. This allows you to create a new object and pass it as a parameter just as you described.

The lifecycle at this time is the responsibility of the callee since the caller has no reference to the object.

The good news is that in 10.2A, garbage collection is being added for OO objects. This means that DELETE OBJECT obj-ref will no longer be necessary although it can be used to force garbage collection and free up any resources held by an object, (provided the destructor frees the resources).

BTW, C++ does not have garbage collection, it is the responsibility of the programmer to delete what they new.

-Shelley

Posted by Tim Kuehn on 18-Jan-2008 16:05

The good news is that in 10.2A, garbage collection is being added for OO objects.

Thanks for your answer Shelley.

Is garbage collection part of 10.2, or not until 10.2A? And if 10.2A, do you know when that's scheduled to be released?

Posted by Shelley Chase on 18-Jan-2008 16:16

At this time garbage collection is scheduled for 10.2A which is scheduled to ship second half of 2008.

-Shelley

This thread is closed