[openbeos] Re: Pointer or reference?

references seem a bit more efficient to me:  pointers require allocation of a 4 
byte space, 
initialization to the address to which they point and dereferencing takes a 
small amount of extra 
time.  i personally like to USE pointers, but when it comes to the design of an 
OS, shouldn't we 
incorporate everything we know?  if we are going to be in the media_kit for 
example and are trying 
to push huge amounts of data around with little latency, perhaps using 
references is different 
enough to improve the speed?

a penny saved is a penny earned.

-jared

---
Jared Eldredge
MNL / Electrical and Computer Engineering
UMass Amherst
----- Original Message -----
From: Waldemar Kornewald
Sent: 3/27/2004 1:32:32 PM
To: openbeos@xxxxxxxxxxxxx
Subject: [openbeos] Re: Pointer or reference?

> > > So, I would say, for public APIs (or those that may become public in the 
> > > future), references should be avoided.
> > 
> > Sadly, I have to agree. 
> 
> References have the advantage that the function/method already says it does 
> not accept NULL 
pointers. The data must always be defined.
> Additionally, when passing a BString object it is much better to pass the 
> reference because you 
cannot forget the &-sign and the code looks nicer:
> 
> BString string;
> ...
> control->SetLabel(string);
> versus
> control->SetLabel(&string);
> 
> I really prefer the reference version. It could also state that the 
> SetLabel() method does not have 
side-effect (i.e.: it does not modify string) which could be useful sometimes.
> 
> Bye,
> Waldemar
> 


Other related posts: