Path: utzoo!attcan!utgpu!watmath!att!bellcore!rutgers!mit-eddie!uw-beaver!tektronix!sequent!mntgfx!lisch
From: lisch@mentor.com (Ray Lischner)
Newsgroups: comp.lang.c++
Subject: Re: named return values
Message-ID: <1989Aug9.175337.12165@mentor.com>
Date: 9 Aug 89 17:53:37 GMT
References: <1826@cmx.npac.syr.edu> <26302@shemp.CS.UCLA.EDU> <6444@columbia.edu>
Organization: Mentor Graphics Corp., Beaverton, OR
Lines: 23
In-reply-to: kearns@read.columbia.edu's message of 9 Aug 89 02:14:05 GMT

In <6444@columbia.edu>, kearns@read.columbia.edu writes that

> m1.plus(matrix(m2).times(2)).plus(m3)

can prevent the "horrible performance" of

> m1 = m1 + 2*m2 + m3;

When m1, m2, and m3 are matrices.

If efficiency is that important, then why not define assignment
operators: +=, *=, etc., to do what you call plus(), times(), etc.:

    tmp = m2;
    tmp *= 2;
    tmp += m3;
    m1 += tmp;

I would still rather write readable code, but if, for a given compiler,
the readable version does perform adequately, then I would rather see
assignment operators than plus(), etc.
-- 
Internet: lisch@mntgfx.mentor.com     UUCP: tektronix!sequent!mntgfx!lisch