<div dir="ltr"><div>First off, apologies for top-posting, fixed below, with some additional comments.<br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Jul 21, 2020 at 11:56 AM Florin Mateoc <<a href="mailto:florin.mateoc@gmail.com">florin.mateoc@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Jul 21, 2020 at 9:21 AM Fabio Niephaus <<a href="mailto:lists@fniephaus.com" target="_blank">lists@fniephaus.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr"><div dir="ltr">On Tue, Jul 21, 2020 at 3:08 PM Marcel Taeumel <<a href="mailto:marcel.taeumel@hpi.de" target="_blank">marcel.taeumel@hpi.de</a>> wrote:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><div id="gmail-m_2454757887348569786gmail-m_2585196494169535867gmail-m_-7263357994648692208__MailbirdStyleContent" style="font-size:10pt;font-family:Arial;color:rgb(0,0,0)">
                                        Maybe I can check for #isImmediateClass first :-)</div></div></blockquote><div><br></div><div>That's a good idea. Note that primitiveSomeInstance also returns nil in case no instance exists (e.g. `EToyProjectDetailsMorph someInstance == nil`).</div><div>I believe the behavior you observe wrt immediates has historical reasons:</div><div>#someInstance returns the first instance found in the object memory, and you can use #nextInstance: for iteration (this mechanism was later replaced by #allInstances). Iterating instances doesn't make sense for immediates, the "same instance" can occur multiple times in the heap.<br></div><div><br></div><div>Fabio</div></div></div></div></blockquote></div></blockquote><div>
<div dir="ltr"><div><br></div><div><br></div><div>Actually, primitiveSomeInstance fails, it does not return nil. It is the image-side primitive failure code that returns nil.</div><div>Which brings us to the question: why not fix it in Smalltalk, if you think the behavior (as implemented in Behavior :)) is not appropriate for immediate classes? <br></div><div>If you override the method in the immediate classes and replace the primitive failure code with something more appropriate for each immediate class, you can have them return good exemplars</div><div><br></div><div>Also note that, as Eliot said, nextInstance does not make sense for immediate classes. This implies that someInstance does not make sense either when thought of as the dual of nextInstace (which it is, in many scenarios). <br></div><div>But I think someInstance can make sense on its own, as in your scenario, that is the context in which I proposed to "fix it"<br></div><div><br></div><div>Florin<br></div></div>  <br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><div id="gmail-m_2454757887348569786gmail-m_2585196494169535867gmail-m_-7263357994648692208__MailbirdStyleContent" style="font-size:10pt;font-family:Arial;color:rgb(0,0,0)"><div></div><blockquote type="cite" style="border-left-style:solid;border-width:1px;margin-top:20px;margin-left:0px;padding-left:10px">
                        <p style="color:rgb(170,170,170);margin-top:10px">Am 21.07.2020 15:07:01 schrieb Marcel Taeumel <<a href="mailto:marcel.taeumel@hpi.de" target="_blank">marcel.taeumel@hpi.de</a>>:</p><div style="font-family:Arial,Helvetica,sans-serif"><div id="gmail-m_2454757887348569786gmail-m_2585196494169535867gmail-m_-7263357994648692208__MailbirdStyleContent" style="font-size:10pt;font-family:Arial;color:rgb(0,0,0)">
                                        
                                        
                                            
                                        
                                        
                                        Hi Fabio.<div><br></div><div>From an object-oriented perspective, it would be nice to get "some instance" when asking a class in the system for #someInstance. :-)</div><div><br></div><div>As it is now, I have to start writing a little lookup table with "class == SmallInteger ifTrue: [ .... ]" to lookup exemplary instances for some classes in the system.</div><div><br></div><div>Best,</div><div>Marcel<br><div><br></div><div><br></div><div></div>
                                        
                                        </div><blockquote type="cite" style="border-left-style:solid;border-width:1px;margin-top:20px;margin-left:0px;padding-left:10px;min-width:500px">
                        <p style="color:rgb(170,170,170);margin-top:10px">Am 21.07.2020 14:53:31 schrieb Fabio Niephaus <<a href="mailto:lists@fniephaus.com" target="_blank">lists@fniephaus.com</a>>:</p><div style="font-family:Arial,Helvetica,sans-serif">
<div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr">On Tue, Jul 21, 2020 at 2:24 PM Marcel Taeumel <<a href="mailto:marcel.taeumel@hpi.de" target="_blank">marcel.taeumel@hpi.de</a>> wrote:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex;min-width:500px"><div id="gmail-m_2454757887348569786gmail-m_2585196494169535867gmail-m_-7263357994648692208gmail-m_-1249618653276569828__MailbirdStyleContent" style="font-size:10pt;font-family:Arial;color:rgb(0,0,0)">Hi all!<div></div><div><br></div><div>Why is "SmallInteger someInstance == nil"?</div></div></blockquote><div><br></div><div>Because SmallIntegers are immediate and cannot be instantiated (`SmallInteger new` fails). This implies:</div><div><br></div><div>"SmallFloat64 someInstance == nil"</div><div>"Character someInstance == nil"</div><div><br></div><div>Why would you want someInstance of SmallInteger anyway?</div><div><br></div><div>Fabio</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex;min-width:500px"><div id="gmail-m_2454757887348569786gmail-m_2585196494169535867gmail-m_-7263357994648692208gmail-m_-1249618653276569828__MailbirdStyleContent" style="font-size:10pt;font-family:Arial;color:rgb(0,0,0)"><div><br></div><div>Best,</div><div>Marcel</div></div><br>
</blockquote></div></div></div></div></div>
</div></blockquote></div></div></blockquote>
                                        </div></div><br>
</blockquote></div></div></div>
<br>
</blockquote></div>
</blockquote></div></div>