Andrew Lentvorski wrote:
> Andrew Lentvorski wrote:
> 
>> You just demonstrated why I now *despise* programming in C++.  It
>> isn't just the language; it's the programmers.
> 
> My apologies.  Rereading that, I was *way* too harsh.  Sorry.

Hehe. I was about to comment to the effect that this is reason to avoid
numerous langauges, and it would certainly include the languages that
have been discussed in this thread.... ;-)

> One of my hot buttons about C++ is programmers who reinvent the wheel
> when there are well-tested libraries that already exist.

C++ is a common tool for component builders, and by their nature
component builders are always trying to build a better component.
Nothing wrong with that really, unless your job isn't to build a better
component. ;-)

> Before creating code like that again, please point people to boost
> *first*.  Novice programmers often don't understand the pitfalls that
> code snippets like that contain.

I have pointed to Boost... I think multiple times. That said, Boost does
not actually have an analogue to what I wrote (I guess their weak_ptr is
pretty close, but it needs to be used in conjunction with shared_ptr),
as their code also deals with resource ownership, which my code sample
did not (in an effort to avoid obfuscating the issue).

Aside from the ownership issues though, I think most of your concerns
are unwarranted. Pointer assignment *isn't* guaranteed to be atomic by
the language and even if it is the code presented should produce the
exact same code for assignment with any decent compiler. I guess a
crappy compiler could find a way to cause problems, and if you also
shared the Ptr across multiple threads without synchronization the
existing dereference logic, but I didn't want to obfuscate the issue by
addressing that at the same time.

--Chris

-- 
[email protected]
http://www.kernel-panic.org/cgi-bin/mailman/listinfo/kplug-lpsg

Reply via email to