gracelang / language

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

can traits contain statefull classes? #150

Closed kjx closed 6 years ago

kjx commented 6 years ago

(this might just be a question of wording - but perhaps it is a deep design question).

Is this legal?

trait partOne {
   class one {
       var x is public := 3
   }
}

The spec says "a trait object is created by an object constructor that contains no field declarations and no executable code". Does this mean directly contains no field declarations at the top level, or transitively contains no field declarations inside it?

Similarly I guess "executable code" means no initialisation code at the top level - but...?

apblack commented 6 years ago

Yes, this is OK. In fact, your example illustrates @kjx's encoding of dialects.

The Spec means "directly contains". We should reword.

apblack commented 6 years ago

I've reworded this in commit cb69601.