Переглянути джерело

Update method syntax in generics overview (#634)

* Implement #494 for overview.md
josh11b 4 роки тому
батько
коміт
9e1816f9c0
1 змінених файлів з 18 додано та 19 видалено
  1. 18 19
      docs/design/generics/overview.md

+ 18 - 19
docs/design/generics/overview.md

@@ -114,7 +114,7 @@ function.
 
 
 This ability to generalize makes `SortVector` a _generic_.
 This ability to generalize makes `SortVector` a _generic_.
 
 
-**NOTE:** The `$` syntax is a placeholder. The syntax is being decided in
+**NOTE:** The `:$` syntax is a placeholder. The syntax is being decided in
 [question-for-leads issue #565](https://github.com/carbon-language/carbon-lang/issues/565).
 [question-for-leads issue #565](https://github.com/carbon-language/carbon-lang/issues/565).
 
 
 ### Interfaces
 ### Interfaces
@@ -150,14 +150,13 @@ Example:
 
 
 ```
 ```
 interface Comparable {
 interface Comparable {
-  // Placeholder method syntax
   // `Less` is an associated method.
   // `Less` is an associated method.
-  method (this: Self) Less(that: Self) -> Bool;
+  fn Less[me: Self](that: Self) -> Bool;
 }
 }
 ```
 ```
 
 
-[Question-for-leads issue #494](https://github.com/carbon-language/carbon-lang/issues/494)
-is on method syntax.
+**Note:** The method syntax was decided in
+[question-for-leads issue #494](https://github.com/carbon-language/carbon-lang/issues/494).
 
 
 Interfaces describe functionality, but not data; no variables may be declared in
 Interfaces describe functionality, but not data; no variables may be declared in
 an interface.
 an interface.
@@ -183,7 +182,7 @@ Consider this interface:
 
 
 ```
 ```
 interface Printable {
 interface Printable {
-  method (this: Self) Print();
+  fn Print[me: Self]();
 }
 }
 ```
 ```
 
 
@@ -200,7 +199,7 @@ struct Song {
   // of the `Song` API.
   // of the `Song` API.
   impl as Printable {
   impl as Printable {
     // Could use `Self` in place of `Song` here.
     // Could use `Self` in place of `Song` here.
-    method (this: Song) Print() { ... }
+    fn Print[me: Song]() { ... }
   }
   }
 }
 }
 
 
@@ -209,13 +208,13 @@ struct Song {
 // the library defining `Song` or `Comparable`.
 // the library defining `Song` or `Comparable`.
 external impl Song as Comparable {
 external impl Song as Comparable {
   // Could use either `Self` or `Song` here.
   // Could use either `Self` or `Song` here.
-  method (this: Self) Less(that: Self) -> Bool { ... }
+  fn Less[me: Self](that: Self) -> Bool { ... }
 }
 }
 ```
 ```
 
 
 **Note:** The interface implementation syntax was decided in
 **Note:** The interface implementation syntax was decided in
 [question-for-leads issue #575](https://github.com/carbon-language/carbon-lang/issues/575).
 [question-for-leads issue #575](https://github.com/carbon-language/carbon-lang/issues/575).
-TODO: move this to details and link.
+TODO: move these syntax issues to details and link.
 
 
 Implementations may be defined within the struct definition itself or
 Implementations may be defined within the struct definition itself or
 externally. External implementations may be defined in the library defining the
 externally. External implementations may be defined in the library defining the
@@ -334,13 +333,13 @@ Interfaces can require other interfaces be implemented:
 
 
 ```
 ```
 interface Equatable {
 interface Equatable {
-  method (this: Self) IsEqual(that: Self) -> Bool;
+  fn IsEqual[me: Self](that: Self) -> Bool;
 }
 }
 
 
 // `Iterable` requires that `Equatable` is implemented.
 // `Iterable` requires that `Equatable` is implemented.
 interface Iterable {
 interface Iterable {
   impl as Equatable;
   impl as Equatable;
-  method (this: Self*) Advance();
+  fn Advance[addr me: Self*]();
 }
 }
 ```
 ```
 
 
@@ -353,13 +352,13 @@ interface.
 // `Hashable` extends `Equatable`.
 // `Hashable` extends `Equatable`.
 interface Hashable {
 interface Hashable {
   extends Equatable;
   extends Equatable;
-  method (this: Self) Hash() -> UInt64;
+  fn Hash[me: Self]() -> UInt64;
 }
 }
 // `Hashable` is equivalent to:
 // `Hashable` is equivalent to:
 interface Hashable {
 interface Hashable {
   impl as Equatable;
   impl as Equatable;
   alias IsEqual = Equatable.IsEqual;
   alias IsEqual = Equatable.IsEqual;
-  method (this: Self) Hash() -> UInt64;
+  fn Hash[me: Self]() -> UInt64;
 }
 }
 ```
 ```
 
 
@@ -370,8 +369,8 @@ methods in the child implementation.
 struct Key {
 struct Key {
   // ...
   // ...
   impl as Hashable {
   impl as Hashable {
-    method (this: Key) IsEqual(that: Key) -> Bool { ... }
-    method (this: Key) Hash() -> UInt64 { ... }
+    fn IsEqual[me: Key](that: Key) -> Bool { ... }
+    fn Hash[me: Key]() -> UInt64 { ... }
   }
   }
   // No need to separately implement `Equatable`.
   // No need to separately implement `Equatable`.
 }
 }
@@ -387,14 +386,14 @@ It gives you all the names that don't conflict.
 
 
 ```
 ```
 interface Renderable {
 interface Renderable {
-  method (this: Self) GetCenter() -> (Int, Int);
+  fn GetCenter[me: Self]() -> (Int, Int);
   // Draw the object to the screen
   // Draw the object to the screen
-  method (this: Self) Draw();
+  fn Draw[me: Self]();
 }
 }
 interface EndOfGame {
 interface EndOfGame {
-  method (this: Self*) SetWinner(player: Int);
+  fn SetWinner[addr me: Self*](player: Int);
   // Indicate the game was a draw
   // Indicate the game was a draw
-  method (this: Self*) Draw();
+  fn Draw[addr me: Self*]();
 }
 }
 
 
 fn F[T:$ Renderable & EndOfGame](game_state: T*) -> (Int, Int) {
 fn F[T:$ Renderable & EndOfGame](game_state: T*) -> (Int, Int) {