<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div>Well,&nbsp;I don't think you'd programmatically create a new class, because your instance has to have been an instance of a class that already exists. Or else you would not have an instance to begin with.&nbsp;</div><div><br></div><div>Perhaps, you want a way to programatically reproduce an instance you've been working with by hand in a Workspace. You have the instance. It's just right. You want it to be programmatically reproducible at will. I'd use Object&gt;&gt;storeString.&nbsp;</div><div><br></div><div><div>x := (HelloWorld new) color: 'Black'.</div><div><br></div><div>I've created a instance with an instvar. I send it storeString:</div><div><span class="Apple-tab-span" style="white-space:pre">        </span></div><div>x storeString&nbsp;</div><div><br></div><div>and I get:&nbsp;</div><div><br></div><div>'(HelloWorld basicNew instVarAt: 1 put: ''Black''; yourself)'</div></div><div><br></div><div>It's a bit crufty to me. I remove the first and last quote and parentheses. The double single quotes aren't great, so I remove them too.&nbsp;</div><div><br></div><div>HelloWorld basicNew instVarAt: 1 put: 'Black'; yourself</div><div><br></div><div>Print it, and get:&nbsp;</div><div><br></div><div>a HelloWorld&nbsp;</div><div><br></div><div>I'm not sure why it comes in some extra syntax.&nbsp;</div><div>That's my best guess at an answer to your question. YMMV.&nbsp;</div><div><br></div><div><br></div><div>Chris&nbsp;</div><div><br></div><div><br></div><div><br></div><br><div><div>On 2012-06-09, at 5:04 PM, Erich Groat wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><br>Hi all,<br><br>I was wondering if there are any built-in facilities for taking a particular instance a class <b>X</b>, call it <b>anX,</b> and creating from it a class method that returns an identical instance of <b>anX</b> for future use.<br>
<br>For example, say I'm futzing around in a workspace with an instance of a class called <b>InteractiveWindowShape</b>, tweaking things so that I have a nice window with all the colors and proportions and buttons I want, perhaps using Morphs to create the thing dynamically (so it's some kind of Morph object). In the course of this I get an instance of <b>anInteractiveWindowShape</b> that I am satisfied with, all the instance variables set just right. Let's call this object<b> | idealShape |</b>. It's just sitting there, rather vulnerably, in a workspace, the result of my using various screen tools over the last half hour. Now, I don't just want to <i>save</i> this object: I want to be able to create an identical one whenever I like. So what I want is a Class method, <b>InteractiveWindowShapes class&gt;&gt;</b><b>newIdealShape,</b> that creates an instance exactly like <b>idealShape.</b><br>
<br>Is there a message I can send <i>to this instance</i> <b>idealShape</b> that would return a block of code that would act as a class method, which I could then call <b>newIdealShape</b>, and which would return an identical instance?<br>
<br>I suspect such a general method might not exist, due to the potential hazards surrounding the deep copy problem; I also suspect I may not be imagining the best sort of solution to my problem. Is there a strategy for this?<br>
<br>Thanks all!<br><br>Erich<br>
_______________________________________________<br>Beginners mailing list<br><a href="mailto:Beginners@lists.squeakfoundation.org">Beginners@lists.squeakfoundation.org</a><br>http://lists.squeakfoundation.org/mailman/listinfo/beginners<br></blockquote></div><br></body></html>