<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On 27 Apr 2013, at 9:24, 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; ">[under the O'CAML rules]<br><br><blockquote type="cite">i.e., this is no longer a valid module:<br></blockquote><blockquote type="cite"> method greet(name : String) {<br></blockquote><blockquote type="cite"> print "Hello, {name}."<br></blockquote><blockquote type="cite"> }<br></blockquote><blockquote type="cite"> greet "visitor"<br></blockquote><blockquote type="cite"><br></blockquote><br>because the last line is a self-call during construction.<br>Right. so *if* we went that way, modules are no longer objects -<br>or we'd have special rules for modules. and REPLs...<br>The original idea was that they'd be methods, not objects, but I<span class="Apple-converted-space"> </span><br>like objects better!<span class="Apple-converted-space"> </span><br></span></blockquote></div><br><div>Yes, I agree that this is a serious problem. The root cause is that we have been using "top level code" in object constructors to do two things.</div><div><br></div><div>(1) In the REPL, and in Modules, it's just code that should be executed asap. In the REPL in particular, we want it executed before the object is completely created, which ca't happen until the END of the object constructor is reached.</div><div><br></div><div>(2) In inherited objects, we want to delay the execution of the top level code until after all of the sub-objects have been created, since the sub-objects might change the meaning of any of that code.</div><div><br></div><div>There desires are fundamentally in conflict. We can eliminate that conflict by banning the offending code. Other proposals are welcome!</div><div><br></div><div>If we do ban executable code in object constructors, then we would need to make modules and "scripts" something else. The obvious choice is methods, but I have to admit that I really dislike the idea of a "main method" as in Java — the name "main" makes it sounds as though that method should be important, whereas in fact it's unimportant.</div><div><br></div><div>Michael is also right that our model for doing procedures-first required the incremental growth of objects by adding methods, which could be requested as soon as they were added, even though the object is incomplete. It does seem a shame to loose that — but I am more concerned with having a sensible semantics for objects than being able to use methods like procedures.</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre"> </span>Andrew</div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div></body></html>