Path: news.mathworks.com!newsfeed-00.mathworks.com!panix!bloom-beacon.mit.edu!llnews!53ab2750!not-for-mail
Newsgroups: comp.soft-sys.matlab
Subject: Re: running other applications
References: <ef5c942.0@webcrossing.raydaftYaTP> <ef5c942.1@webcrossing.raydaftYaTP> <ef5c942.2@webcrossing.raydaftYaTP> <f6lh2p$4ie$1@fred.mathworks.com> <1183731582.111910.293480@w3g2000hsg.googlegroups.com> <ef5c942.6@webcrossing.raydaftYaTP>
From: Peter Boettcher <boettcher@ll.mit.edu>
Message-ID: <muy3b01qvfh.fsf@G99-Boettcher.llan.ll.mit.edu>
Organization: MIT Lincoln Laboratory
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.98 (gnu/linux)
Cancel-Lock: sha1:f//VLxNbo0zKhOA91OwvAWeZkXc=
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Lines: 46
Date: Fri, 06 Jul 2007 13:44:02 -0400
NNTP-Posting-Host: 155.34.163.114
X-Complaints-To: news@ll.mit.edu
X-Trace: llnews 1183743613 155.34.163.114 (Fri, 06 Jul 2007 13:40:13 EDT)
NNTP-Posting-Date: Fri, 06 Jul 2007 13:40:13 EDT
Xref: news.mathworks.com comp.soft-sys.matlab:417631



"Jeremy Smith" <smit1729@umn.NOSPAM.edu> writes:

> What is the difference between 'system' and '!' besides 'system'
> returning results?
>
> Why is there such a strong aversion to using 'eval'? I realize there
> is usually a better way of accomplishing the task programmatically
> but I tend to see fairly strong opposition to using 'eval' overall.

Since the string to be eval'd is built dynamically, the MATLAB engine
can't accelerate anything containing an eval.  In fact, even the
parsing of the string has to happen as the eval is called, rather
than the entire m-file being preparsed.

There used to be serious issues with the compiler and eval.  I think
that stuff has been resolved with the new compiler, but I don't know.

Finally, readability suffers.  String concatenation, number-to-string
conversion (also affects performance!), double and quadruple quotes,
etc.


Code that passes through CSSM that uses eval usually indicates one of
several problems:
- Intuitive desire to use sequentially named variables.  (Do other
languages like VBasic use this?)  Cell arrays are almost always the
best thing to use instead, for performance and readability reasons.
- Not understanding "command/function duality", which lets you replace
"load fname" with "load('fname')"
- Not understanding the difference between literal strings and string
variables (I think related to the former)

A few obvious comparisons:

eval(['A' num2str(i) ' = myfunctioncall(' num2str(i) ');' ]);
A{i} = myfunctioncall(i);

eval(['load ' myfile ';'])
load(myfile);


So there have it.  Computationally slow, hard to read/write/maintain,
indicator of deeper programming knowledge issues which I like to think I
can help address.

-Peter