Newsgroups: comp.lang.smalltalk
Path: cantaloupe.srv.cs.cmu.edu!das-news2.harvard.edu!oitnews.harvard.edu!purdue!lerc.nasa.gov!magnus.acs.ohio-state.edu!math.ohio-state.edu!howland.reston.ans.net!news.sprintlink.net!uunet!utcsri!info.physics.utoronto.ca!ie.utoronto.ca!news
From: Gene Golovchinsky <golovch>
Subject: Re: Q: Class name as parameter for object construction
X-Nntp-Posting-Host: entrop.ie
Content-Type: text/plain; charset=iso-8859-1
Message-ID: <DAJxI9.FyK.0.ie@ie.utoronto.ca>
Sender: news@ie.utoronto.ca (USENET News Administrator)
Content-Transfer-Encoding: 7bit
Organization: Dept. Of Industrial Engineering, University Of Toronto
References: <21@aiware.in-berlin.de>
Mime-Version: 1.0
Date: Thu, 22 Jun 1995 01:58:57 GMT
X-Mailer: Mozilla 1.1b3 (X11; I; SunOS 4.1.3_U1 sun4m)
X-Url: news:21@aiware.in-berlin.de
Lines: 34

scm@aiware.in-berlin.de (Harald Schmidt) wrote:
>Hi,
>
>   I would like to write a methode like:
>
>      initArrayWith: nameOfClass
>      | object |
>      object := nameOfClass new.
>
>   but this doesn't work because nameOfClass is of type String.
>   So, my question is how to convert the String into a real 
>   class name. I am using VST3win

When you refer to a specific class in Smalltalk, you usually
refer to it by its name which the compiler looks up in the
Smalltalk (the sole instance of SystemDictionary). You can
do that lookup yourself when necessary"

initArrayWith: nameOfClass
	|object class |
	class := Smalltalk at: nameOfClass asSymbol ifAbsent: [nil].
	class isBehavior
		ifTrue: [object := class new]
		ifFalse: ["you've got an unknown class name"].
	"do something with object"


 2
G
-- 
Gene Golovchinsky
University of Toronto 
http://anarch.ie.utoronto.ca/people/golovch/

