[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: object-model: Return by value, reference or pointer? (or something else?)

From: Steinar Bang <sb_at_dod.no>
Date: Wed, 13 Oct 2010 21:42:00 +0200

>>>>> "Hyrum K. Wright" <hyrum_wright_at_mail.utexas.edu>:

> Refcounting smartpointers are used to avoid duplication of the
> underlying C structures, but they are completely private. I've got
> serious reservations about exposing that complexity in the external
> object interfaces. Given those reservations, the API would just
> return a vanilla pointer, which leaves the caller the responsibility
> of freeing it.

Here I'm not following you. You would hide the complexity of smart
pointers, and would return plain pointers?

Hm... the first I wouldn't worry about, and on the second I would go to
great lenghts to make it hard to get at the plain pointers.

At least if we're talking about a variant of your alternative 2.

>> Generally 1 gives a nicer API.  But if you have any inheritance and
>> virtual methods going, then 2 is simplest.

> No inheritance or virtual stuff, as of yet, so not a concern.

Ok, that makes it simpler. Then go for 1. I would have inheritance
here to make a SPOC for the refcounting, but it could be done without
virtual methods.
Received on 2010-10-13 21:42:52 CEST

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.