typedefs and structs

Zan Lynx zlynx at acm.org
Wed Nov 9 11:13:48 EST 2005


On Wed, 2005-11-09 at 10:57 +1100, David Gibson wrote:
> On Tue, Nov 08, 2005 at 05:23:27PM -0600, Linas Vepstas wrote:
[snip]
> > The ampersand says "pass argument by reference (so as to get arg passing
> > efficiency) but force coder to write code as if they were passing by value"
> > As a result, it gets difficult to pass null pointers (for reasons
> > similar to the difficulty of passing null pointers in Java (and yes,
> > I loathe Java, sorry to subject you to that))  Anyway, that's a C++ trick 
> > only; I wish it was in C so I could experiment more and find out if I 
> > like it or hate it.
> 
> I hate it: it obscures the fact that it's a pass-by-reference at the
> callsite, which is useful information.  Although this is, admittedly,
> the least confusing use of C++ reference types.

I agree with you about that one.  It's yet another thing for C
programmers to have to learn to watch for C++ doing behind your back.

However, it isn't any worse than having an ordinary C pointer to some
struct.  If the pointer was passed to the current function from above,
and you're passing it to another function below, you really don't know
what's going to happen to the structure unless you go look.  Just like
the C++ reference, the C pointer doesn't get an address-of operator to
remind you.
-- 
Zan Lynx <zlynx at acm.org>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : http://ozlabs.org/pipermail/linuxppc64-dev/attachments/20051108/8dd7c5d6/attachment.pgp 


More information about the Linuxppc64-dev mailing list