[Grace-core] How to Program in Grace

James Noble kjx at ecs.vuw.ac.nz
Wed Nov 21 15:54:54 PST 2012


> In attempting to track down a compiler bug, I've realized that the code that I wrote and tested last summer no longer compiles.  Well, it's not legal Grace, so I supposed that I shouldn't complain.
> 
> I had created a number of objects like this:
> 
> def assertionTrait:Assertion = object {

yes - I know this seems sensible, and is certainly how we used to do things...

> That inherits clause is illegal by the current rules.  The compiler doesn't complain about it, but does complain that the object created does not have the type that I think it should have.

right - and it (or some kind of static check) should...

> Now I don't know how to write this code in Grace.  "Copy and Paste inheritance" is not a good idea.  The best that I could come up with was
> 
> class assertion.trait -> Assertion {

right - or the other option should be a method that returns an object.
> 

> and then inheriting from the class constructor:
> 
> object {
>             inherits assertion.trait
>             def tests = list.new

did that work for you?

> But it gets worse!  I also had object constructers with multiple methods, which used to inherit some of those methods from super object constructors, while overriding one of them (the one that actually did the construction).  How should I write those?

has to be a method that returns a new object, methinks?

James


More information about the Grace-core mailing list