[Grace-core] initialisation & checking

Andrew P. Black black at cs.pdx.edu
Sat Apr 27 17:40:46 PDT 2013


On 27 Apr 2013, at 9:24, James Noble wrote:

> [under the O'CAML rules]
> 
>> i.e., this is no longer a valid module:
>>   method greet(name : String) {
>>       print "Hello, {name}."
>>   }
>>   greet "visitor"
>> 
> 
> because the last line is a self-call during construction.
> Right. so *if* we went that way, modules are no longer objects -
> or we'd have special rules for modules. and REPLs...
> The original idea was that they'd be methods, not objects, but I 
> like objects better! 

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.

(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.

(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.

There desires are fundamentally in conflict.   We can eliminate that conflict by banning the offending code.  Other proposals are welcome!

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.

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.

	Andrew





-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailhost.cecs.pdx.edu/pipermail/grace-core/attachments/20130427/125ef56d/attachment.html>


More information about the Grace-core mailing list