Re: [Alephmodular-devel] Random rumblings on files and errors
Status: Pre-Alpha
Brought to you by:
brefin
From: Michael A. <mdm...@ya...> - 2003-01-30 22:27:52
|
> > [8.6] When should I use references, and when > should I use pointers? > > > http://www.parashift.com/c++-faq-lite/references.html#faq-8.6 > > Funny, I didn't realize I'm an "Old line C > programmer" :)... this FAQ > entry states (among other things): > > > Note: Old line C programmers sometimes don't like > references since they > > provide reference semantics that isn't explicit in > the caller's code. > > After some C++ experience, however, one quickly > realizes this is a form > > of information hiding, which is an asset rather > than a liability. > I have to agree with you on that one. I don't have every function call memorized. So if I see: foo(a); I assume 'a' won't be changed, but: foo(&a); Kind of lets me know a will be changed. In my opinion refs should only be const and used to avoid parameter copy costs for big structures. So: foo (&a); *Means* that a is meant to be changed, but a function of type: void foo(const Bar &a); is only doing the ref because Bar is really big and we don't want the efficiency cost of pass-by-value. And really who cares whether you type a->x vs a.x. Maybe if you had to do (*a).x sort of stuff, but that is rare. Just my opinion, Michael D. Adams mdm...@ya... __________________________________________________ Do you Yahoo!? Yahoo! Mail Plus - Powerful. Affordable. Sign up now. http://mailplus.yahoo.com |