<html><head></head><body bgcolor="#FFFFFF"><div>Maybe worth noting that #storeString might not work so well with a Morph that's visible in the World... IIRC that ends up trying to store the whole World, because Morphs hang onto a reference to their current World.</div><div><br></div><div>It will work as long as there aren't cycles and it's not in the current world.</div><div><br></div><div>In the menu of a workspace, there's an option to create references from dropped Morphs. I think the way I hustled around the problem was by dropping my handmade Morph into the workspace to get a reference, then detaching the Morph from the world with the halo (the workspace has a reference so the Morph doesn't meet the great garbage collector in the sky.)</div><div><br></div><div>#storeString and #storeOn: are fun:)<br><br>On Jun 9, 2012, at 2:37 PM, Chris Cunnington &lt;<a href="mailto:smalltalktelevision@gmail.com">smalltalktelevision@gmail.com</a>&gt; wrote:<br><br></div><div></div><blockquote type="cite"><div><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><a href="http://lists.squeakfoundation.org/mailman/listinfo/beginners">http://lists.squeakfoundation.org/mailman/listinfo/beginners</a><br></blockquote></div><br></div></blockquote><blockquote type="cite"><div><span>_______________________________________________</span><br><span>Beginners mailing list</span><br><span><a href="mailto:Beginners@lists.squeakfoundation.org">Beginners@lists.squeakfoundation.org</a></span><br><span><a href="http://lists.squeakfoundation.org/mailman/listinfo/beginners">http://lists.squeakfoundation.org/mailman/listinfo/beginners</a></span><br></div></blockquote></body></html>