From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Why does everyone hate 'eval'?
Date: Sat, 13 Dec 2008 16:16:02 +0000 (UTC)
Organization: NTNU
Lines: 22
Message-ID: <gi0n41$ap4$>
References: <ghrlim$oqo$> <ghv5ut$fj7$>
Reply-To: <HIDDEN>
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: 1229184962 11044 (13 Dec 2008 16:16:02 GMT)
NNTP-Posting-Date: Sat, 13 Dec 2008 16:16:02 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 651407
Xref: comp.soft-sys.matlab:506745

"us " <> wrote in message <ghv5ut$fj7$>...
> "Johan Carlson"
> > I've been running into comments like "NO, NO, NO, WHATEVER YOU DO,  DO NOT USE EVAL!!!!' in various posts during the past few weeks...
> these lovely people are absolutely correct - and - let me add this, after having used > ML for 26 years - there is absolutely NO evil eval, which you cannot possibly replace >by a genuine string of ML commands or stock functions...
> us

Then maybe you can help me out.

I have the name of a Matlab class stored in a string variable, S. I would like to construct a metaclass object for the class named in the variable, S. Right now I'm doing
>> mc = eval(['?',S]);
>> mc = metaclass(eval(s));

How can I avoid using eval here? Mathwork support has been unable to help me.

NB! Note that in the 2008a-documentation it says that you can do
>> mc = metaclass(S);
This is wrong and has been corrected in the newer documentation.