From d1a98252a96c989cfb31002746402491996f6fb7 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Fri, 26 Apr 2019 21:38:22 +0200 Subject: [PATCH] Polishings --- .../reference/contextual-instance/conversions.md | 2 +- .../contextual-instance/import-implied.md | 14 +++++++------- .../reference/contextual-instance/instance-defs.md | 6 +++--- .../contextual-instance/relationship-implicits.md | 4 ++-- .../reference/contextual/relationship-implicits.md | 2 +- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/docs/docs/reference/contextual-instance/conversions.md b/docs/docs/reference/contextual-instance/conversions.md index 31e61d928cbc..725fa566fd0d 100644 --- a/docs/docs/reference/contextual-instance/conversions.md +++ b/docs/docs/reference/contextual-instance/conversions.md @@ -14,7 +14,7 @@ instance of Conversion[String, Token] { def apply(str: String): Token = new KeyWord(str) } ``` -Using an instance alias, this can be expressed more concisely as: +Using an alias instance, this can be expressed more concisely as: ```scala instance of Conversion[String, Token] = new KeyWord(_) ``` diff --git a/docs/docs/reference/contextual-instance/import-implied.md b/docs/docs/reference/contextual-instance/import-implied.md index b4e7cc723620..afe32da41c3c 100644 --- a/docs/docs/reference/contextual-instance/import-implied.md +++ b/docs/docs/reference/contextual-instance/import-implied.md @@ -18,7 +18,7 @@ object B { In the code above, the `import A._` clause of object `B` will import all members of `A` _except_ the instance `tc`. Conversely, the second import `import instance A._` will import _only_ that instance. -Generally, a normal import clause brings all members except implicit instance values into scope whereas an `import instance` clause brings only implicit instance values into scope. +Generally, a normal import clause brings all members except implicit instances into scope whereas an `import instance` clause brings only implicit instances into scope. There are two main benefits arising from these rules: @@ -32,15 +32,15 @@ There are two main benefits arising from these rules: ### Relationship with Old-Style Implicits -The rules of evidence imports above have the consequence that a library +The rules of instance imports above have the consequence that a library would have to migrate in lockstep with all its users from old style implicit definitions and -normal imports to evidence definitions and evidence imports. +normal imports to instance definitions and instance imports. The following modifications avoid this hurdle to migration. - 1. An evidence import also brings old style implicits into scope. So, in Scala 3.0 + 1. An instance import also brings old style implicits into scope. So, in Scala 3.0 an old-style implicit definition can be brought into scope either by a normal or - by an evidence import. + by an instance import. 2. In Scala 3.1, an old-style implicits accessed implicitly through a normal import will give a deprecation warning. @@ -48,6 +48,6 @@ The following modifications avoid this hurdle to migration. 3. In some version after 3.1, an old-style implicits accessed implicitly through a normal import will give a compiler error. -These rules mean that library users can use `import evidence` to access old-style implicits in Scala 3.0, +These rules mean that library users can use `import instance` to access old-style implicits in Scala 3.0, and will be gently nudged and then forced to do so in later versions. Libraries can then switch to -evidence definitions once their user base has migrated. +instance definitions once their user base has migrated. diff --git a/docs/docs/reference/contextual-instance/instance-defs.md b/docs/docs/reference/contextual-instance/instance-defs.md index 229d448b81e6..cc40a8354b65 100644 --- a/docs/docs/reference/contextual-instance/instance-defs.md +++ b/docs/docs/reference/contextual-instance/instance-defs.md @@ -46,9 +46,9 @@ instance [T] given (ord: Ord[T]) of Ord[List[T]] { ... } ``` If a name is not given, the compiler will synthesize one from the type(s) in the `for` clause. -## instance Aliases +## Alias Instances -An instance alias defines an implicit instance that is equal to some expression. E.g., assuming a global method `currentThreadPool` returning a value with a member `context`, one could define: +An alias instance defines an implicit instance that is equal to some expression. E.g., assuming a global method `currentThreadPool` returning a value with a member `context`, one could define: ```scala instance ctx of ExecutionContext = currentThreadPool().context ``` @@ -59,7 +59,7 @@ Alias instances may be anonymous, e.g. ```scala instance of Position = enclosingTree.position ``` -An instance alias can have type and context parameters just like any other instance definition, but it can only implement a single type. +An alias instance can have type and context parameters just like any other instance definition, but it can only implement a single type. ## Syntax diff --git a/docs/docs/reference/contextual-instance/relationship-implicits.md b/docs/docs/reference/contextual-instance/relationship-implicits.md index 30f15eafd4a8..61af35456ffa 100644 --- a/docs/docs/reference/contextual-instance/relationship-implicits.md +++ b/docs/docs/reference/contextual-instance/relationship-implicits.md @@ -139,7 +139,7 @@ Implicit classes in Scala 2 are often used to define extension methods, which ar ### Implicit Values -Implicit `val` definitions in Scala 2 can be expressed in Dotty using a regular `val` definition and an instance alias. E.g., Scala 2's +Implicit `val` definitions in Scala 2 can be expressed in Dotty using a regular `val` definition and an alias instance. E.g., Scala 2's ```scala lazy implicit val pos: Position = tree.sourcePos ``` @@ -151,7 +151,7 @@ can be expressed in Dotty as ### Abstract Implicits -An abstract implicit `val` or `def` in Scala 2 can be expressed in Dotty using a regular abstract definition and an instance alias. E.g., Scala 2's +An abstract implicit `val` or `def` in Scala 2 can be expressed in Dotty using a regular abstract definition and an alias instance. E.g., Scala 2's ```scala implicit def symDeco: SymDeco ``` diff --git a/docs/docs/reference/contextual/relationship-implicits.md b/docs/docs/reference/contextual/relationship-implicits.md index d5c98f0fe420..9643e0eafe60 100644 --- a/docs/docs/reference/contextual/relationship-implicits.md +++ b/docs/docs/reference/contextual/relationship-implicits.md @@ -137,7 +137,7 @@ Implicit classes in Scala 2 are often used to define extension methods, which ar ### Implicit Values -Implicit `val` definitions in Scala 2 can be expressed in Dotty using a regular `val` definition and an instance alias. E.g., Scala 2's +Implicit `val` definitions in Scala 2 can be expressed in Dotty using a regular `val` definition and an alias instance. E.g., Scala 2's ```scala lazy implicit val pos: Position = tree.sourcePos ```