On Tuesday 01 September 2009 10:25:23 Jeff Hill wrote:
>
> The controversy arises, of course, surrounding
> changing the gdd interface which is in use.
My suggestion (as a complete outsider, I have never had to write code that
uses GDDs, so feel free to completely ignore me) was to not change the GDD
API at all (since doing so would break existing code) and instead to swallow
the awkward GDD behavior in the smartGDDPointer.
> Unfortunately, unless one removes referencing, and also new, from the gdd
> interface, then this still does not prevent someone from inadvertently
> doing this. This type of unfortunate pitfall is what Alex and others have
> experienced - and complained about.
>
> gdd * pGDD = new gdd();
> ...
> smartGDDPointer pDD1; // Empty
> pDD1.newGdd(); //create 1st one
> ...
> smartGDDPointer pDD1 = pGDD; // replace with 2nd, woops forgot to call
> pGDD->unreferenced()
But in that example, the user is still using a gdd* and calling new gdd(),
whereas they should probably make pGDD a smartGDDPointer too, at which point
the bug disappears.
There may be places where you might still want/need to use gdd* pointers, but
but hopefully they can be minimized.
> BTW: Is there a reason why you have a preference:
> // this
> smartGDDPointer pDD1; // Empty
> pDD1.newGdd(); // Create one
> // versus this (what I would probably implement lacking further input)
> smartGDDPointer pDD1 = gdd :: factory (); // Create one
>
> A messy aspect of factories is that one must replicate all of the various
> ctor signatures for the various modes of the target. I think that there are
> six of them with gdd. Maybe not so bad.
I was trying to avoid changing the GDD API; given that it has existing users
and a limited lifetime it's probably a bad idea to force them to change their
code now (since you're going to be doing that anyway when DA comes in), so
you would have to leave the existing constructors in place. I thought it
would be better to extend the smartGDDPointer API, since it's already
gdd-specific and that's where you're trying to encourage people to go anyway.
- Andrew
--
The best FOSS code is written to be read by other humans -- Harold Welte
- References:
- About the reference counting in GDD smart pointer Alex . Chen
- Re: About the reference counting in GDD smart pointer Andrew Johnson
- RE: About the reference counting in GDD smart pointer Jeff Hill
- Navigate by Date:
- Prev:
RE: About the reference counting in GDD smart pointer Jeff Hill
- Next:
Re: main trunk base build failure win32-x86 Andrew Johnson
- Index:
2002
2003
2004
2005
2006
2007
2008
<2009>
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
- Navigate by Thread:
- Prev:
RE: About the reference counting in GDD smart pointer Jeff Hill
- Next:
RE: About the reference counting in GDD smart pointer Alex . Chen
- Index:
2002
2003
2004
2005
2006
2007
2008
<2009>
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
|