Andrei Alexandrescu wrote:
Max Samukha wrote:
On Tue, 20 Oct 2009 18:12:39 +0800, Lionello Lunesu
<[email protected]> wrote:

On 20-10-2009 6:38, Andrei Alexandrescu wrote:
I hereby suggest we get rid of new for class object creation. What do
you guys think?
I don't agree with this one.

There's extra cost involved, and the added keyword makes that clear. Also, somebody mentioned using 'new' to allocate structs on the heap; I've never actually done that, but it sounds like using 'new' would be the perfect way to do just that.

L.

I don't think the extra cost should be emphasized with 'new' every
time you instantiate a class. For example, in C#, they use 'new' for
creating structs on stack (apparently to make them consistent with
classes, in a silly way).

I think the rarer cases when a class instance is allocated in-place (a
struct on heap) can be handled by the library.

BTW, why "in-situ" is better in this context than the more common
"in-place"? Would be nice to know.

The term originated with this:

class A {
    InSitu!B b;
    ...
}

meaning that B is embedded inside A. But I guess InPlace is just as good.


Andrei

I actually do not understand what InSitu is supposed to mean.

I like the name Scope, but InPlace works for me.

Reply via email to