D
Dale King
Paul said:Newbie confusion isn't my concern and reduction of it shouldn't
be the guiding principle of a programming language.
I think newbie confusion is really not strong enough a word. Frankly, I
think something like this may trip up old-timers as well. The
distinction between value semantics and reference semantics is probably
not very clear to many C++ programmers.
Why not just use stack-based objects?
Because it is unsafe and unsecure as others have explained.
Going back to where I started where I talked about 3 aspects of the end
of the lifecycle for an object:
1. Releasing of non-memory resources
2. Freeing of the object's memory
3. Elimination of the last reference to an object.
Stack-based objects allow 2 to occur before 3 which causes problems. The
real question is why is it assumed that 1 and 2 have to occur together?
That is the way C++ does it, but is that really the best way? I don't
think so. All we really care about is that 1 occurs before 2 and we
would like 1 to occur in a timely fashion. The using mechanism is one
way to do this.