opencog-dev team mailing list archive
-
opencog-dev team
-
Mailing list archive
-
Message #00210
Re: Smart pointers and OpenCog
I am not a C++ guru ... but from what I do know, I think that removing
the SmartPointers would probably be a bad idea
A better plan would probably be to get rid of the old-fashioned
pointers and replace them with SmartPointers, but that would be too
much work for right now...
Smart pointers are essentially just a class that holds a single
pointer and will delete it in the destructor. The point being that
whenever you allocate some memory on the heap you immediately wrap a
smart pointer object around it and then it will automatically be
deleted when that object goes out of scope, regardless of whether that
was through normal exit or throwing an exception.
How would mixing these w/ regular pointers in the same problem cause
any problem? The smart pointers will get smartly deleted, and the
regular pointers will (hopefully!!) get manually deleted...
ben
On Mon, Jun 16, 2008 at 6:34 AM, Joel Pitt <joel.pitt@xxxxxxxxx> wrote:
> Hi all,
>
> I'm currently looking through the PTL code Ari wrote which will be the
> basis for PLN in OpenCog.
>
> I've noticed the use of smart pointer construct boost::smart_ptr in
> the code, and I can't remember where I heard this, but I think it's a
> general rule of thumb to avoid mixing pointer types in a piece of
> software.
>
> So this brings up the subject of whether we should use smart pointers
> in OpenCog, or whether I should try to factor out the boost smart
> pointers... or if we should just ignore this, as I may be misguided in
> my idealisations of using only one type of pointer system.
>
> I must admit my experience with smart pointers is quite limited, I've
> only used them during my brief stint on AGISim (CrystalSpace made
> liberally use of them I think).
>
> J
>
> _______________________________________________
> Mailing list: https://launchpad.net/~opencog-dev
> Post to : opencog-dev@xxxxxxxxxxxxxxxxxxx
> Unsubscribe : https://launchpad.net/people/+me/+editemails
> More help : https://help.launchpad.net/ListHelp
>
--
Ben Goertzel, PhD
CEO, Novamente LLC and Biomind LLC
Director of Research, SIAI
ben@xxxxxxxxxxxx
"Nothing will ever be attempted if all possible objections must be
first overcome " - Dr Samuel Johnson
Follow ups
References