|
Boost Users : |
Subject: Re: [Boost-users] [Smart Ptr] Why is weak_ptr a _ptr?
From: Szymon Gatner (szymon.gatner_at_[hidden])
Date: 2010-10-13 18:06:56
>
> I just think of it (loosely) as an object that has a chance (determined at
> runtime) of being convertible to a shared_ptr. A lot like boost::optional
> really.
>
>> It should rather be called shared_tracker or shared_listener or something
>> in that taste ;)
>
> Everybody who's ever used a garbage collected system should know what "weak"
> refers to in this context. I don't know what a "tracker" is supposed to be,
> and this thing doesn't sound much like a "listener" either.
>
> Play the name game to its logical conclusion and eventually it won't make a
> bit of sense to anyone. :-)
>
I do agree that names I proposed are bad ;) In fact they suggest that
I am against
"weak"part of weak_ptr's name which is nothing I had in mind. I do get
the purpose they
serve and the reason they exist. I do understand the concept of weak
references also.
My only objection is strictly about "_ptr" part of the name which suggests it is
a pointer-like type which is just not true. I see them as extension or even part
of shared_ptr implementation. A token or a proxy if you will.
Current standard has only one "_ptr". Next one is going to have bunch more.
All of them having common (quite expected) interface. What will you answer to
a C++ newbie when asked "what a C++ smart pointer is?". Is it really
any type that
"has a chance of being convertible to a [whatever]_ptr"?
Szymon
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net