title: Io: How to instantiate a subclassed primitive (e.g. Number)?
body: <p>In the book <a href="http://pragprog.com/book/btlang/seven-languages-in-seven-weeks" rel="nofollow noreferrer">7 Languages in 7 Weeks</a> there is a question:</p>
  
  <blockquote>
    <p>How would you change / to return 0 if the denominator is zero?</p>
  </blockquote>
  
  <p>Thanks to the thread <a href="https://stackoverflow.com/questions/8282911/whats-the-significance-of-self-inside-of-a-method">What&#39;s the significance of self inside of a method?</a> I have a working solution, but I wanted to try to do it without clobbering the Number "/" method, and instead subclass Number. Here is what I tried:</p>
  
  <pre><code>Zeroable := Number clone
  Zeroable / = method(denom, if(denom == 0, 0, self proto / denom))
  </code></pre>
  
  <p>However, this doesn't work. If I try to instantiate an instance of Zeroable, it behaves just like a number:</p>
  
  <pre><code>Io&gt; ten := Zeroable 10
  ==&gt; 10
  Io&gt; ten type
  ==&gt; Number
  Io&gt; ten / 5
  ==&gt; 2
  Io&gt; ten / 0
  ==&gt; inf
  Io&gt; ten slotNames
  ==&gt; list()
  </code></pre>
  
  <p>If I instantiate the Zeroable the "normal" way it works, but the value is always 0 and there doesn't appear to be a way to change it:</p>
  
  <pre><code>Io&gt; zero := Zeroable clone
  ==&gt; 0
  Io&gt; zero type
  ==&gt; Zeroable
  Io&gt; zero / 0
  ==&gt; 0
  Io&gt; zero / 2
  ==&gt; 0
  </code></pre>
  
  <p>I think the issue is the way that <code>ten</code> is instantiated, but I cannot figure out how to pass "arguments" to a clone method, or otherwise how to create a Zeroable that is not 0. What is going on here?</p>