Path: news.mathworks.com!not-for-mail
From: Loren Shure <loren@mathworks.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Using functions and structures sensibly
Date: Thu, 8 May 2008 17:31:01 -0400
Organization: The MathWorks
Lines: 24
Message-ID: <MPG.228d3b1c5922277989851@news.mathworks.com>
References: <fvuu3s$bd$1@fred.mathworks.com> <fvv6bf$4gd$1@fred.mathworks.com> <fvv8qq$1d8$1@canopus.cc.umanitoba.ca>
NNTP-Posting-Host: shurel.dhcp.mathworks.com
Mime-Version: 1.0
Content-Type: text/plain; charset="iso-8859-15"
Content-Transfer-Encoding: 7bit
X-Trace: fred.mathworks.com 1210282261 27864 172.31.57.117 (8 May 2008 21:31:01 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Thu, 8 May 2008 21:31:01 +0000 (UTC)
User-Agent: MicroPlanet-Gravity/2.70.2067
Xref: news.mathworks.com comp.soft-sys.matlab:467501



In article <fvv8qq$1d8$1@canopus.cc.umanitoba.ca>, roberson@ibd.nrc-
cnrc.gc.ca says...
> In article <fvv6bf$4gd$1@fred.mathworks.com>,
> someone  <someone@somewhere.net> wrote:
> 
> >The only reason why I know modifying inputs "is bad" is 
> >that MATLAB will pass the inputs by value (instead of by 
> >reference).  But, one way or another, you are creating 
> >another copy of myStruct anyway.
> 
> I -gather- (perhaps incorrectly) from other postings that the
> special case of having the same variable on input and output
> of a function is handled by modifying the variable in-place
> rather than creating a copy of the variable (other than
> if the variable happens to share data with another variable.)
> 

Sometimes...  depends on how it's called from the caller (same right and 
left hand side name required) AND requires the calculation to be do-able 
inplace.

-- 
Loren
http://blogs.mathworks.com/loren/