gracelang / language

Design of the Grace language and its libraries
GNU General Public License v2.0
6 stars 1 forks source link

statically tracking that a trait is incomplete (uncooked)? #56

Open kjx opened 8 years ago

kjx commented 8 years ago

how can we statically track that a trait is a trait and not a cooked object?

this must be related to type system for ensuring completely initialisation, but is an easier bit I think!

kjx commented 8 years ago

are there two separate issues there:

Uncooked is horrible. Please, raw to mean "uninitialised" not at least "execution of bottom-most object constructor has not completed normally".

kjx commented 8 years ago

I think I meant to make this about incomplete.

We could e.g. stop people instantiating traits directly (somehow).

  myTrait

would be a dynamic error. The incompleteness tagging would ensure myTrait had a type that meant something horrid. But of course

  object { 
     uses myTrait
  }

would still be OK, however the incompleteness analysis should spot that the trait was missing methods and so at least wouldn't give this object a type it considered complete?

apblack commented 8 years ago

There is no issue of traits being cooked or uncooked — by design, they require no initialization. I suggest that @kjx remove all mention of cooking from the above comments.

Yes, I think that it's quite feasible to track whether or not a trait is complete, and if not, what its open requirements are. The Smalltalk traits browser did this in real time in 2002. That (the real-time update) was a bit tricky, inspiring many of the patterns in "A Pattern Language for Extensible Program Representation". But doing it in a compiler should be pretty simple.

Long term, I would like a Grace IDE to do this tracking.