Path: news.mathworks.com!newsfeed-00.mathworks.com!kanaga.switch.ch!switch.ch!newsfeed.inode.at!newsfeed.utanet.at!newsspool.utanet.at!not-for-mail
From: Michael Salloker <michael.NO.SPAM.salloker@fh-joanneum.at>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Pass by Reference?
Date: Fri, 02 Jun 2006 10:20:59 +0200
Organization: UTA Telekom AG (Customer)
Lines: 68
Message-ID: <e5osdd$gg7$1@newsreader1.utanet.at>
References: <ef386cf.-1@webcrossing.raydaftYaTP> <447f5e07$0$18308$ba4acef3@news.orange.fr>
NNTP-Posting-Host: fh.fh-joanneum.at
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 7bit
X-Trace: newsreader1.utanet.at 1149236461 16903 62.218.221.187 (2 Jun 2006 08:21:01 GMT)
X-Complaints-To: abuse@uta.at
NNTP-Posting-Date: 2 Jun 2006 08:21:01 GMT
User-Agent: Mozilla Thunderbird 1.0.7 (Windows/20050923)
X-Accept-Language: de-DE, de, en-us, en
In-Reply-To: <447f5e07$0$18308$ba4acef3@news.orange.fr>
Xref: news.mathworks.com comp.soft-sys.matlab:353034



CRet schrieb:
> HI,
> 
> As long as you only have one object to pass. Why not simply declare it as
> global ?
> 
> I know, global variables are not recommended but it will greatly simplify
> argument passing.
> This is only a suggestion. I will not be reponsible of any lost of data,
> property damage, personal injury, lost of time in development or maintenance
> of the code. Even be involve in the future problematic evolution of your
> application since I forcast that you will in a close futur have two or three
> of this large object to handel simultaneously.
> 
> Remember, integrety of your aobject will be difficult to maintain, since all
> functions or scripts  which declare it as global may modify or delete it
> expectively or unexpectively. This make sametime debugging really hard for
> large project. If you are leading a developer team, be sure co-workers
> respect naming rules and access policy to your base workspace and disk paths
> !
> 
> If some one here or there ask me if I give you this advice. I will denie. I
> will say that I never use any global variable, or I only have one time, a
> long time ago, on low RAM system, few disk space networks, no GUI, only
> command line intructions setup, on slow micro-WAX machines, reading  large
> data set (concept of objects was not establish) from kilometric magnetic
> tapes, unsing MATLAB ver2 or 3...
> At this time, global variable was the only change we have to run the
> project.
> 
> Hope this help.
> 
> C.Ret
> 
> P.S.: "very slow" means how many days of computations ? I remenber that
> former project when the first steps to prepare the large data set from raw
> acquisitions was about 72h.
> 
>     If  "very slow" means 1 or 2 mins, there is perhaps no benefit to
> investigate time in modifying and debugging your actual code. Think at the
> time gained at future evolutions or developments of your already well
> structurated data object and code compared to difficult evolution of an
> unstructurated code using global workspace.
> 
> 
> "Brandon Aubie" <brandon.aubie@TAKETHISOUTelecore.com> wrote in
> news:ef386cf.-1@webcrossing.raydaftYaTP...
> 
>>Hi,
>>
>>Is there a "proper" way to pass objects by reference? We need to
>>pass a large object around NUMEROUS times (ie, >10000) and it's
>>very slow. Passing by reference would speed this up tremendously.
>>
>>Thanks
> 
> 
> 

I would not recommend global variables, the reasons are posted in this 
forum often, and are discussed much.

An alternative approach is the use of nested functions. A nested 
function can access the variables of all functions in which it is 
nested. So ther is no need to pass any parameter.

Michael