From 48cf61097cbcf6a2631d957428983f9aaeb4fdbf Mon Sep 17 00:00:00 2001 From: Josh L Date: Thu, 13 Jan 2022 13:01:25 -0800 Subject: [PATCH 1/2] Clarify class declaration syntax. --- docs/design/classes.md | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/docs/design/classes.md b/docs/design/classes.md index 0eb8bebbda7d6..5ee0edaa75b24 100644 --- a/docs/design/classes.md +++ b/docs/design/classes.md @@ -676,9 +676,10 @@ for argument passing were decided in The declarations for nominal class types will have: +- an optional `abstract` or `base` prefix - `class` introducer - the name of the class -- in the future, we will have optional modifiers for inheritance +- an optional `extends` followed by the name of the immediate base class - `{`, an open curly brace - a sequence of declarations - `}`, a close curly brace @@ -705,10 +706,13 @@ determined at compile time. To support circular references between class types, we allow [forward declaration](https://en.wikipedia.org/wiki/Forward_declaration) of -types. A type that is forward declared is considered incomplete until the end of -a definition with the same name. +types. Forward declarations end with semicolon `;` after the name of the class, +instead of any `extends` caluse and the block of declarations in curly braces +`{`...`}`. A type that is forward declared is considered incomplete until the +end of a definition with the same name. ``` +// Forward declaration of `GraphNode`. class GraphNode; class GraphEdge { @@ -719,6 +723,7 @@ class GraphEdge { class GraphNode { var edges: Vector(GraphEdge*); } +// `GraphNode` is first complete here. ``` **Open question:** What is specifically allowed and forbidden with an incomplete From 75de4bec9d5b966b2fba2522eff788ce5e5facc7 Mon Sep 17 00:00:00 2001 From: josh11b Date: Fri, 14 Jan 2022 14:22:15 -0800 Subject: [PATCH 2/2] Apply suggestions from code review Co-authored-by: Richard Smith --- docs/design/classes.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/design/classes.md b/docs/design/classes.md index 5ee0edaa75b24..232a4de363c32 100644 --- a/docs/design/classes.md +++ b/docs/design/classes.md @@ -707,7 +707,7 @@ determined at compile time. To support circular references between class types, we allow [forward declaration](https://en.wikipedia.org/wiki/Forward_declaration) of types. Forward declarations end with semicolon `;` after the name of the class, -instead of any `extends` caluse and the block of declarations in curly braces +instead of any `extends` clause and the block of declarations in curly braces `{`...`}`. A type that is forward declared is considered incomplete until the end of a definition with the same name.