<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On 22 Jul 2013, at 4:36, James Noble wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><span class="Apple-style-span" style="border-collapse: separate; font-family: Calibri; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; ">for the repl.<span class="Apple-converted-space"> </span><br>You need to allow<span class="Apple-converted-space"> </span><br><br>def x = 3<br>...<br>def x = 7<span class="Apple-converted-space"> </span><br><br>in the same session<span class="Apple-converted-space"> </span><br></span></blockquote><br></div><div>No, we don't. You are still thinking of "repl" in terms of a teletype. Nowadays, we have editing buffers. If you want to redefine x to be 7, all you need to is edit the 3 to be a 7, and press the "evaluate" button. That evaluates the entire contents of the buffer again.</div><div><br></div><div>I would not expect an object with two definitions of aCat or two definitions of x to compile. </div><div><br></div><div>However, classes are not definitions; they are special, since they combine a definition with an object expression. We could allow multiple class constructs with the same object name and different factory method names to be additive. Then we would be able to write:</div><div><br></div><div><blockquote type="cite">class aCat.named(n)withColor(c) {<br></blockquote><blockquote type="cite"> def name = n<br></blockquote><blockquote type="cite"> def color = c<br></blockquote><blockquote type="cite"> method speak { </blockquote><blockquote type="cite"><span class="Apple-tab-span" style="white-space:pre"> </span>print "I'm a {color} cat; my name is {name}"</blockquote><blockquote type="cite"> }</blockquote><blockquote type="cite">}<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">class aCat.named(n) {<br></blockquote><blockquote type="cite"> aCat.named(n)withColor("blue")<br></blockquote><blockquote type="cite">}</blockquote></div><br><div>This would create a factory object aCat with two methods, named()withColor() and named(). Notice that there is no reason to use inheritance in the method 'named'; both of the factory methods create objects with the same method suite, and there is no inheritance relationship between them.</div><div><br></div><div>I'm not sure myself if this is worth the cost, but it would seem to be the simplest way of allowing students to move from factories with a single method to factories with multiple methods.</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre"> </span>Andrew</div><div><br></div></body></html>