[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: Mark Reibert <svn_at_reibert.com>
Date: Thu, 14 Oct 2010 22:13:32 -0700

> -------- Original Message --------
> Subject: RE: object-model: Return by value, reference or pointer? (or
> something else?)
> From: "Bolstridge, Andrew" <andy.bolstridge_at_intergraph.com>
> Date: Thu, October 14, 2010 5:24 am
> To: <dev_at_subversion.apache.org>

[snip]

> Personally, I would stick to just returning a string, or if it is
> essential to return a null value, return a string and an null indicator
> - your choice whether that's best as a pair, or an out parameter. I
> would not inherit from std::string, nor would I throw an exception (not
> that anyone's yet suggested that - we're not C# or Java programmers
> after all :-) )

I like that - and the out parameter is actually the place to use a
pointer so callers can decide whether or not they care about the
difference between null and empty:

    std::string getAuthor( bool* isNull = 0 ) const { /* ... */ }

Callers who care about null-ness can check for it with little more
effort (and a slightly clumsier API) than an isNull() method.
Received on 2010-10-15 07:14:14 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.