Re: typedefs and structs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 <[email protected]>

Attachment: signature.asc
Description: This is a digitally signed message part


[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux