Path: news.mathworks.com!newsfeed-00.mathworks.com!newsfeed2.dallas1.level3.net!news.level3.com!postnews.google.com!p2g2000prf.googlegroups.com!not-for-mail
From: Praetorian <ashish.sadanandan@gmail.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Why does everyone hate 'eval'?
Date: Sat, 13 Dec 2008 18:10:18 -0800 (PST)
Organization: http://groups.google.com
Lines: 66
Message-ID: <9e91603f-17c3-4e81-ad47-33379c3e8b95@p2g2000prf.googlegroups.com>
References: <ghrlim$oqo$1@fred.mathworks.com> <ghv5ut$fj7$1@fred.mathworks.com> 
	<4b2672cf-f966-4714-a857-82abaa812e6d@z27g2000prd.googlegroups.com> 
	<gi1ev6$l3f$1@fred.mathworks.com>
NNTP-Posting-Host: 24.8.188.226
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
X-Trace: posting.google.com 1229220618 15104 127.0.0.1 (14 Dec 2008 02:10:18 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Sun, 14 Dec 2008 02:10:18 +0000 (UTC)
Complaints-To: groups-abuse@google.com
Injection-Info: p2g2000prf.googlegroups.com; posting-host=24.8.188.226; 
	posting-account=uxNuEQoAAABwxsrGxAKeLxAj2hdO1tck
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.4) 
	Gecko/2008102920 Firefox/3.0.4,gzip(gfe),gzip(gfe)
Xref: news.mathworks.com comp.soft-sys.matlab:506806

On Dec 13, 4:03=A0pm, "?yvind" <oyv...@gmail.com> wrote:
> Praetorian <ashish.sadanan...@gmail.com> wrote in message <4b2672cf-f966-=
4714-a857-82abaa812...@z27g2000prd.googlegroups.com>...
> > > Then maybe you can help me out.
>
> > > I have the name of a Matlab class stored in a string variable, S. I w=
ould=3D
> > =A0like to construct a metaclass object for the class named in the vari=
able, =3D
> > S. Right now I'm doing
>
> > > >> mc =3D3D eval(['?',S]);
> > > or,
> > > >> mc =3D3D metaclass(eval(s));
>
> > > How can I avoid using eval here? Mathwork support has been unable to =
help=3D
> > =A0me.
>
> > > NB! Note that in the 2008a-documentation it says that you can do>> mc=
 =3D3D=3D
> > =A0metaclass(S);
>
> > > This is wrong and has been corrected in the newer documentation.
>
> > > ?yvind
>
> > >> version
>
> > ans =3D3D
>
> > 7.7.0.471 (R2008b)
>
> > >> s =3D3D 'memmapfile';
> > >> m =3D3D metaclass(['?', s])
>
> > m =3D3D
>
> > =A0 meta.class handle
> > =A0 Package: meta
>
> > =A0 Properties:
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0Name: 'char'
> > =A0 =A0 =A0 =A0 =A0 =A0 Description: ''
> > =A0 =A0 DetailedDescription: ''
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0Hidden: 0
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0Sealed: 1
> > =A0 =A0 =A0 =A0 ConstructOnLoad: 1
> > =A0 =A0 =A0 =A0 InferiorClasses: {0x1 cell}
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0Properties: {[1x1 meta.property]}
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 Methods: {136x1 cell}
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0Events: {0x1 cell}
> > =A0 =A0 =A0 =A0 =A0 =A0SuperClasses: {0x1 cell}
> > =A0 =A0 =A0 ContainingPackage: {}
>
> > =A0 Methods, Events, Superclasses
>
> Is this an answer to my question? As you can see for yourself your approa=
ch doesn't work, like I said.
>
> ?yvind

What do you mean it doesn't work? I retrieved the metaclass
information for a class whose name was stored in a string variable
without using EVAL. Isn't that what you wanted? Anyway, Doug has a
solution that doesn't even require string concatenation.