Skip to content

Commit 982c51f

Browse files
committed
Add small improvements to the Reference page
1 parent 5b7a8dd commit 982c51f

22 files changed

+53
-78
lines changed

docs/_docs/reference/changed-features/compiler-plugins.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,18 @@ title: "Changes in Compiler Plugins"
44
nightlyOf: https://docs.scala-lang.org/scala3/reference/changed-features/compiler-plugins.html
55
---
66

7-
Compiler plugins are supported by Dotty (and Scala 3) since 0.9. There are two notable changes
8-
compared to `scalac`:
7+
Compiler plugins are supported in Scala 3 since Dotty 0.9. There are two notable changes
8+
compared to Scala 2:
99

1010
- No support for analyzer plugins
1111
- Added support for research plugins
1212

13-
[Analyzer plugins][1] in `scalac` run during type checking and may influence
13+
[Analyzer plugins][1] run in Scala 2 during type checking and may influence
1414
normal type checking. This is a very powerful feature but for production usages,
1515
a predictable and consistent type checker is more important.
1616

1717
For experimentation and research, Scala 3 introduces _research plugin_. Research plugins
18-
are more powerful than `scalac` analyzer plugins as they let plugin authors customize
18+
are more powerful than Scala 2 analyzer plugins as they let plugin authors customize
1919
the whole compiler pipeline. One can easily replace the standard typer by a custom one or
2020
create a parser for a domain-specific language. However, research plugins are only
2121
enabled for nightly or snaphot releases of Scala 3.
@@ -26,7 +26,7 @@ _standard plugins_ in Scala 3. In terms of features, they are similar to
2626

2727
## Using Compiler Plugins
2828

29-
Both standard and research plugins can be used with `scalac` by adding the `-Xplugin:` option:
29+
In Scala 3, both standard and research plugins can be used with `scalac` by adding the `-Xplugin:` option:
3030

3131
```shell
3232
scalac -Xplugin:pluginA.jar -Xplugin:pluginB.jar Test.scala
@@ -40,7 +40,7 @@ the fully qualified plugin class name. The format of a property file is as follo
4040
pluginClass=dividezero.DivideZero
4141
```
4242

43-
This is different from `scalac` plugins that required a `scalac-plugin.xml` file.
43+
This is different from Scala 2 plugins that require a `scalac-plugin.xml` file.
4444

4545
Starting from 1.1.5, `sbt` also supports Scala 3 compiler plugins. Please refer to the
4646
[`sbt` documentation][2] for more information.

docs/_docs/reference/changed-features/eta-expansion-spec.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ implicit val bla: Double = 1.0
5151
val bar = foo // val bar: Int => Float = ...
5252
```
5353

54-
## Automatic Eta-Expansion and query types
54+
## Automatic Eta-Expansion and context types
5555

5656
A method with context parameters can be expanded to a value of a context type by writing the expected context type explicitly.
5757

@@ -66,7 +66,7 @@ val bar: Double ?=> Float = foo(3)
6666
- If `m` is has an empty argument list (i.e. has type `()R`):
6767
1. If the expected type is of the form `() => T`, we eta expand.
6868
2. If m is defined by Java, or overrides a Java defined method, we insert `()`.
69-
3. Otherwise we issue an error of the form:
69+
3. Otherwise we issue an error of the form: `method must be called with () argument`
7070

7171
Thus, an unapplied method with an empty argument list is only converted to a function when a function type is expected. It is considered best practice to either explicitly apply the method to `()`, or convert it to a function with `() => m()`.
7272

docs/_docs/reference/changed-features/main-functions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ final class happyBirthday:
7272
case error: CLP.ParseError => CLP.showError(error)
7373
```
7474

75-
**Note**: The `<static>` modifier above expresses that the `main` method is generated
75+
**Note:** The `<static>` modifier above expresses that the `main` method is generated
7676
as a static method of class `happyBirthday`. It is not available for user programs in Scala. Regular "static" members are generated in Scala using objects instead.
7777

7878
[`@main`](https://scala-lang.org/api/3.x/scala/main.html) methods are the recommended scheme to generate programs that can be invoked from the command line in Scala 3. They replace the previous scheme to write program as objects with a special `App` parent class. In Scala 2, `happyBirthday` could be written also like this:

docs/_docs/reference/contextual/by-name-context-parameters.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ In the example above, the definition of `s` would be expanded as follows.
5353

5454
```scala
5555
val s = summon[Test.Codec[Option[Int]]](
56-
optionCodec[Int](using intCodec)
56+
using optionCodec[Int](using intCodec)
5757
)
5858
```
5959

docs/_docs/reference/contextual/givens.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@ that serve for synthesizing arguments to [context parameters](./using-clauses.md
1010
```scala
1111
trait Ord[T]:
1212
def compare(x: T, y: T): Int
13-
extension (x: T) def < (y: T) = compare(x, y) < 0
14-
extension (x: T) def > (y: T) = compare(x, y) > 0
13+
extension (x: T)
14+
def < (y: T) = compare(x, y) < 0
15+
def > (y: T) = compare(x, y) > 0
1516

1617
given intOrd: Ord[Int] with
1718
def compare(x: Int, y: Int) =
@@ -51,7 +52,7 @@ given [T](using Ord[T]): Ord[List[T]] with
5152
If the name of a given is missing, the compiler will synthesize a name from
5253
the implemented type(s).
5354

54-
**Note** The name synthesized by the compiler is chosen to be readable and reasonably concise. For instance, the two instances above would get the names:
55+
**Note:** The name synthesized by the compiler is chosen to be readable and reasonably concise. For instance, the two instances above would get the names:
5556

5657
```scala
5758
given_Ord_Int
@@ -62,7 +63,7 @@ The precise rules for synthesizing names are found [here](./relationship-implici
6263
given instances of types that are "too similar". To avoid conflicts one can
6364
use named instances.
6465

65-
**Note** To ensure robust binary compatibility, publicly available libraries should prefer named instances.
66+
**Note:** To ensure robust binary compatibility, publicly available libraries should prefer named instances.
6667

6768
## Alias Givens
6869

docs/_docs/reference/contextual/multiversal-equality.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ that derives `CanEqual`, e.g.
3333
```scala
3434
class T derives CanEqual
3535
```
36+
> Normally a [derives clause](./derivation.md) accepts only type classes with one parameter, however there is a special case for `CanEqual`.
3637
3738
Alternatively, one can also provide a `CanEqual` given instance directly, like this:
3839

@@ -82,7 +83,7 @@ def canEqualAny[L, R]: CanEqual[L, R] = CanEqual.derived
8283
```
8384

8485
Even though `canEqualAny` is not declared as `given`, the compiler will still
85-
construct an `canEqualAny` instance as answer to an implicit search for the
86+
construct a `canEqualAny` instance as answer to an implicit search for the
8687
type `CanEqual[L, R]`, unless `L` or `R` have `CanEqual` instances
8788
defined on them, or the language feature `strictEquality` is enabled.
8889

@@ -156,10 +157,10 @@ Instances are defined so that every one of these types has a _reflexive_ `CanEqu
156157
- Primitive numeric types can be compared with subtypes of `java.lang.Number` (and _vice versa_).
157158
- `Boolean` can be compared with `java.lang.Boolean` (and _vice versa_).
158159
- `Char` can be compared with `java.lang.Character` (and _vice versa_).
159-
- Two sequences (of arbitrary subtypes of `scala.collection.Seq`) can be compared
160+
- Two sequences (arbitrary subtypes of `scala.collection.Seq`) can be compared
160161
with each other if their element types can be compared. The two sequence types
161162
need not be the same.
162-
- Two sets (of arbitrary subtypes of `scala.collection.Set`) can be compared
163+
- Two sets (arbitrary subtypes of `scala.collection.Set`) can be compared
163164
with each other if their element types can be compared. The two set types
164165
need not be the same.
165166
- Any subtype of `AnyRef` can be compared with `Null` (and _vice versa_).

docs/_docs/reference/contextual/type-classes.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ given Functor[List] with
8282
x.map(f) // List already has a `map` method
8383
```
8484

85-
With this `given` instance in scope, everywhere a `Functor` is expected, the compiler will accept a `List` to be used.
85+
With this `given` instance in scope, everywhere a type with a `Functor` context bound is expected, the compiler will accept a `List` to be used.
8686

8787
For instance, we may write such a testing method:
8888

@@ -214,7 +214,7 @@ instead of
214214
show(compute(i)(config))(config)
215215
```
216216

217-
Let's define this m then. First, we are going to define a type named `ConfigDependent` representing a function that when passed a `Config` produces a `Result`.
217+
Let's define this `flatMap` then. First, we are going to define a type named `ConfigDependent` representing a function that when passed a `Config` produces a `Result`.
218218

219219
```scala
220220
type ConfigDependent[Result] = Config => Result

docs/_docs/reference/dropped-features/delayed-init.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ object HelloWorld extends App {
1818
```
1919

2020
However, the code is now run in the initializer of the object, which on
21-
some JVM's means that it will only be interpreted. So, better not use it
21+
some JVMs means that it will only be interpreted. So, better not use it
2222
for benchmarking! Also, if you want to access the command line arguments,
2323
you need to use an explicit `main` method for that.
2424

docs/_docs/reference/experimental/canthrow.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ try
124124
body
125125
catch ...
126126
```
127-
Note that the right-hand side of the synthesized given is `???` (undefined). This is OK since
127+
Note that the right-hand side of the synthesized given is `compiletime.erasedValue`. This is OK since
128128
this given is erased; it will not be executed at runtime.
129129

130130
**Note 1:** The [`saferExceptions`](https://scala-lang.org/api/3.x/scala/runtime/stdLibPatches/language$$experimental$$saferExceptions$.html) feature is designed to work only with checked exceptions. An exception type is _checked_ if it is a subtype of

docs/_docs/reference/experimental/cc.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ def f(x: {c}-> Int): Int
176176
```
177177
Here, the actual argument to `f` is allowed to use the `c` capability but no others.
178178

179-
**Note**: It is strongly recommended to write the capability set and the arrow `->` without intervening spaces,
179+
**Note:** It is strongly recommended to write the capability set and the arrow `->` without intervening spaces,
180180
as otherwise the notation would look confusingly like a function type.
181181

182182
## Subtyping and Subcapturing

0 commit comments

Comments
 (0)