[mythtv] API suggestions

Derek Atkins warlord at MIT.EDU
Fri Feb 6 15:17:36 EST 2004


Renchi Raju <renchi at pooh.tam.uiuc.edu> writes:

> this is just plain stupid and should have been obvious. you created
> something on the stack and returned it by reference. if it wasn't obvious
> i was referring to returning a const reference to a member data.

Unfortunately this is stupid, too, unless it's a const reference to
CONST data, in which case why do you need a function to return it?  If
it's non-const data then you have the potential for multiple threads
to call into the function and thread-b changes the referenced data out
from under thread-a, leading to bad Juju.

It's VERY RARE to have a situation where returning a reference is the
Right Thing, so it's just better to tell people not to do it.

> renchi

-derek

-- 
       Derek Atkins, SB '93 MIT EE, SM '95 MIT Media Laboratory
       Member, MIT Student Information Processing Board  (SIPB)
       URL: http://web.mit.edu/warlord/    PP-ASEL-IA     N1NWH
       warlord at MIT.EDU                        PGP key available


More information about the mythtv-dev mailing list