Skip to content

Commit 90ed18b

Browse files
committed
more fixes in Markdown files
1 parent 33b710a commit 90ed18b

15 files changed

+58
-57
lines changed

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ The precise steps for synthesizing an argument for a by-name context parameter o
4242

4343
1. If this search succeeds with expression `E`, and `E` contains references to `lv`, replace `E` by
4444

45-
4645
```scala
4746
{ given lv: T = E; lv }
4847
```

docs/docs/reference/contextual/conversions.md

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -37,40 +37,40 @@ If such an instance `C` is found, the expression `e` is replaced by `C.apply(e)`
3737
1. The `Predef` package contains "auto-boxing" conversions that map
3838
primitive number types to subclasses of `java.lang.Number`. For instance, the
3939
conversion from `Int` to `java.lang.Integer` can be defined as follows:
40-
```scala
41-
given int2Integer: Conversion[Int, java.lang.Integer] =
42-
java.lang.Integer.valueOf(_)
43-
```
40+
```scala
41+
given int2Integer: Conversion[Int, java.lang.Integer] =
42+
java.lang.Integer.valueOf(_)
43+
```
4444

4545
2. The "magnet" pattern is sometimes used to express many variants of a method. Instead of defining overloaded versions of the method, one can also let the method take one or more arguments of specially defined "magnet" types, into which various argument types can be converted. Example:
46-
```scala
47-
object Completions {
46+
```scala
47+
object Completions {
4848

49-
// The argument "magnet" type
50-
enum CompletionArg {
51-
case Error(s: String)
52-
case Response(f: Future[HttpResponse])
53-
case Status(code: Future[StatusCode])
54-
}
55-
object CompletionArg {
49+
// The argument "magnet" type
50+
enum CompletionArg {
51+
case Error(s: String)
52+
case Response(f: Future[HttpResponse])
53+
case Status(code: Future[StatusCode])
54+
}
55+
object CompletionArg {
5656

57-
// conversions defining the possible arguments to pass to `complete`
58-
// these always come with CompletionArg
59-
// They can be invoked explicitly, e.g.
60-
//
61-
// CompletionArg.fromStatusCode(statusCode)
57+
// conversions defining the possible arguments to pass to `complete`
58+
// these always come with CompletionArg
59+
// They can be invoked explicitly, e.g.
60+
//
61+
// CompletionArg.fromStatusCode(statusCode)
6262

63-
given fromString : Conversion[String, CompletionArg] = Error(_)
64-
given fromFuture : Conversion[Future[HttpResponse], CompletionArg] = Response(_)
65-
given fromStatusCode : Conversion[Future[StatusCode], CompletionArg] = Status(_)
66-
}
67-
import CompletionArg._
63+
given fromString : Conversion[String, CompletionArg] = Error(_)
64+
given fromFuture : Conversion[Future[HttpResponse], CompletionArg] = Response(_)
65+
given fromStatusCode: Conversion[Future[StatusCode], CompletionArg] = Status(_)
66+
}
67+
import CompletionArg._
6868

69-
def complete[T](arg: CompletionArg) = arg match {
70-
case Error(s) => ...
71-
case Response(f) => ...
72-
case Status(code) => ...
73-
}
74-
}
75-
```
69+
def complete[T](arg: CompletionArg) = arg match {
70+
case Error(s) => ...
71+
case Response(f) => ...
72+
case Status(code) => ...
73+
}
74+
}
75+
```
7676
This setup is more complicated than simple overloading of `complete`, but it can still be useful if normal overloading is not available (as in the case above, since we cannot have two overloaded methods that take `Future[...]` arguments), or if normal overloading would lead to a combinatorial explosion of variants.

docs/docs/reference/contextual/relationship-implicits.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
layout: doc-page
3-
title: Relationship with Scala 2 Implicits
3+
title: "Relationship with Scala 2 Implicits"
44
---
55

66
Many, but not all, of the new contextual abstraction features in Scala 3 can be mapped to Scala 2's implicits. This page gives a rundown on the relationships between new and old features.
@@ -11,7 +11,7 @@ Many, but not all, of the new contextual abstraction features in Scala 3 can be
1111

1212
Given instances can be mapped to combinations of implicit objects, classes and implicit methods.
1313

14-
1. Given instances without parameters are mapped to implicit objects. E.g.,
14+
1. Given instances without parameters are mapped to implicit objects. For instance,
1515

1616
```scala
1717
given intOrd: Ord[Int] with { ... }
@@ -23,7 +23,7 @@ Given instances can be mapped to combinations of implicit objects, classes and i
2323
implicit object intOrd extends Ord[Int] { ... }
2424
```
2525

26-
2. Parameterized givens are mapped to combinations of classes and implicit methods. E.g.,
26+
2. Parameterized givens are mapped to combinations of classes and implicit methods. For instance,
2727

2828
```scala
2929
given listOrd[T](using ord: Ord[T]): Ord[List[T]] with { ... }
@@ -70,7 +70,7 @@ The synthesized type names are formed from
7070

7171
1. the prefix `given_`,
7272
2. the simple name(s) of the implemented type(s), leaving out any prefixes,
73-
3. the simple name(s) of the toplevel argument type constructors to these types.
73+
3. the simple name(s) of the top-level argument type constructors to these types.
7474

7575
Tuples are treated as transparent, i.e. a type `F[(X, Y)]` would get the synthesized name
7676
`F_X_Y`. Directly implemented function types `A => B` are represented as `A_to_B`. Function types used as arguments to other type constructors are represented as `Function`.

docs/docs/reference/dropped-features/package-objects.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,23 +25,23 @@ implicit object Cops {
2525
extension (x: C) def pair(y: C) = (x, y)
2626
}
2727
```
28-
There may be several source files in a package containing such toplevel definitions, and source files can freely mix toplevel value, method, and type definitions with classes and objects.
28+
There may be several source files in a package containing such top-level definitions, and source files can freely mix top-level value, method, and type definitions with classes and objects.
2929

30-
The compiler generates synthetic objects that wrap toplevel definitions falling into one of the following categories:
30+
The compiler generates synthetic objects that wrap top-level definitions falling into one of the following categories:
3131

3232
- all pattern, value, method, and type definitions,
3333
- implicit classes and objects,
3434
- companion objects of opaque type aliases.
3535

36-
If a source file `src.scala` contains such toplevel definitions, they will be put in a synthetic object named `src$package`. The wrapping is transparent, however. The definitions in `src` can still be accessed as members of the enclosing package.
36+
If a source file `src.scala` contains such top-level definitions, they will be put in a synthetic object named `src$package`. The wrapping is transparent, however. The definitions in `src` can still be accessed as members of the enclosing package.
3737

38-
**Note 1:** This means that the name of a source file containing wrapped toplevel definitions is relevant for binary compatibility. If the name changes, so does the name of the generated object and its class.
38+
**Note 1:** This means that the name of a source file containing wrapped top-level definitions is relevant for binary compatibility. If the name changes, so does the name of the generated object and its class.
3939

40-
**Note 2:** A toplevel main method `def main(args: Array[String]): Unit = ...` is wrapped as any other method. If it appears
40+
**Note 2:** A top-level main method `def main(args: Array[String]): Unit = ...` is wrapped as any other method. If it appears
4141
in a source file `src.scala`, it could be invoked from the command line using a command like `scala src$package`. Since the
4242
"program name" is mangled it is recommended to always put `main` methods in explicitly named objects.
4343

44-
**Note 3:** The notion of `private` is independent of whether a definition is wrapped or not. A `private` toplevel definition is always visible from everywhere in the enclosing package.
44+
**Note 3:** The notion of `private` is independent of whether a definition is wrapped or not. A `private` top-level definition is always visible from everywhere in the enclosing package.
4545

46-
**Note 4:** If several toplevel definitions are overloaded variants with the same name,
46+
**Note 4:** If several top-level definitions are overloaded variants with the same name,
4747
they must all come from the same source file.

docs/docs/reference/features-classification.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ These constructs replace existing constructs with the aim of making the language
4141
- [Extension Methods](contextual/extension-methods.md) replace implicit classes with a clearer and simpler mechanism.
4242
- [Opaque Type Aliases](other-new-features/opaques.md) replace most uses
4343
of value classes while guaranteeing absence of boxing.
44-
- [Toplevel definitions](dropped-features/package-objects.md) replace package objects, dropping syntactic boilerplate.
44+
- [Top-level definitions](dropped-features/package-objects.md) replace package objects, dropping syntactic boilerplate.
4545
- [Export clauses](other-new-features/export.md)
4646
provide a simple and general way to express aggregation, which can replace the
4747
previous facade pattern of package objects inheriting from classes.

docs/docs/reference/metaprogramming/inline.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ Inline methods can override other non-inline methods. The rules are as follows:
188188
### Relationship to `@inline`
189189

190190
Scala 2 also defines a `@inline` annotation which is used as a hint
191-
for the backend to inline. The `inline` modifier is a more powerful
191+
for the backend to inline code. The `inline` modifier is a more powerful
192192
option: Expansion is guaranteed instead of best effort,
193193
it happens in the frontend instead of in the backend, and it also applies
194194
to recursive methods.
@@ -293,7 +293,7 @@ val one: 1 = zero() + 1
293293

294294
## Inline Conditionals
295295

296-
If the condition of an if-then-else expressions is a constant expression then it simplifies to
296+
An if-then-else expression whose condition is a constant expression can be simplified to
297297
the selected branch. Prefixing an if-then-else expression with `inline` enforces that
298298
the condition has to be a constant expression, and thus guarantees that the conditional will always
299299
simplify.

docs/docs/reference/metaprogramming/macros-spec.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,8 @@ private def dynamicPower(x: Double, n: Int): Double =
196196
else x * dynamicPower(x, n - 1)
197197
```
198198

199+
This assumes a `.value` that maps tree nodes representing constants to their values.
200+
199201
With the right extractors, the "AsFunction" conversion
200202
that maps expressions over functions to functions over expressions can
201203
be implemented in user code:

docs/docs/reference/new-types/dependent-function-types-spec.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ FunctionN[K1, ..., Kn, R'] {
3333
where the result type parameter `R'` is the least upper approximation of the
3434
precise result type `R` without any reference to value parameters `x1, ..., xN`.
3535

36-
The syntax and sementics of anonymous dependent functions is identical to the
36+
The syntax and semantics of anonymous dependent functions is identical to the
3737
one of regular functions. Eta expansion is naturally generalized to produce
3838
dependent function types for methods with dependent result types.
3939

docs/docs/reference/new-types/type-lambdas-spec.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ title: "Type Lambdas - More Details"
99
Type ::= ... | TypeParamClause ‘=>>’ Type
1010
TypeParamClause ::= ‘[’ TypeParam {‘,’ TypeParam} ‘]’
1111
TypeParam ::= {Annotation} (id [HkTypeParamClause] | ‘_’) TypeBounds
12-
TypeBounds ::= [‘>:’ Type] [‘<:’ Type]
12+
TypeBounds ::= [‘>:’ Type] [‘<:’ Type]
1313
```
1414

1515
### Type Checking
@@ -31,7 +31,7 @@ Then `TL1 <: TL2`, if
3131
`L1 <: L2` and `U2 <: U1`),
3232
- `R1 <: R2`
3333

34-
Here we have relied on alpha renaming to match the two bound types `X`.
34+
Here we have relied on [alpha renaming](https://en.wikipedia.org/wiki/Lambda_calculus#%CE%B1-conversion) to match the two bound types `X`.
3535

3636
A partially applied type constructor such as `List` is assumed to be equivalent to
3737
its eta expansion. I.e, `List = [X] =>> List[X]`. This allows type constructors to be compared with type lambdas.

docs/docs/reference/other-new-features/export.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,8 @@ It is a standard recommendation to prefer composition over inheritance. This is
9999
So far, object oriented languages including Scala made it much easier to use inheritance than composition. Inheritance only requires an `extends` clause whereas composition required a verbose elaboration of a sequence of forwarders. So in that sense, OO languages are pushing
100100
programmers to a solution that is often too powerful. Export clauses redress the balance. They make composition relationships as concise and easy to express as inheritance relationships. Export clauses also offer more flexibility than extends clauses since members can be renamed or omitted.
101101

102-
Export clauses also fill a gap opened by the shift from package objects to toplevel definitions. One occasionally useful idiom that gets lost in this shift is a package object inheriting from some class. The idiom is often used in a facade like pattern, to make members
103-
of internal compositions available to users of a package. Toplevel definitions are not wrapped in a user-defined object, so they can't inherit anything. However, toplevel definitions can be export clauses, which supports the facade design pattern in a safer and
102+
Export clauses also fill a gap opened by the shift from package objects to top-level definitions. One occasionally useful idiom that gets lost in this shift is a package object inheriting from some class. The idiom is often used in a facade like pattern, to make members
103+
of internal compositions available to users of a package. Top-level definitions are not wrapped in a user-defined object, so they can't inherit anything. However, top-level definitions can be export clauses, which supports the facade design pattern in a safer and
104104
more flexible way.
105105

106106
### Syntax changes:

docs/docs/reference/other-new-features/indentation.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ if x < 0 then
101101
```
102102

103103
Indentation tokens are only inserted in regions where newline statement separators are also inferred:
104-
at the toplevel, inside braces `{...}`, but not inside parentheses `(...)`, patterns or types.
104+
at the top-level, inside braces `{...}`, but not inside parentheses `(...)`, patterns or types.
105105

106106
### Optional Braces Around Template Bodies
107107

docs/docs/reference/other-new-features/matchable.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ extended by both `AnyVal` and `AnyRef`. Since `Matchable` is a supertype of ever
7272
- Type parameters and abstract types that are only bounded by some
7373
universal trait: Again, `Matchable` should be added as a bound.
7474

75-
Here is the hierarchy of toplevel classes and traits with their defined methods:
75+
Here is the hierarchy of top-level classes and traits with their defined methods:
7676

7777
```scala
7878
abstract class Any:

docs/docs/reference/other-new-features/opaques-details.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,9 @@ defined on the underlying type. For instance,
7575
x == y // uses Int equality for the comparison.
7676
```
7777

78-
### Toplevel Opaque Types
78+
### Top-level Opaque Types
7979

80-
An opaque type alias on the toplevel is transparent in all other toplevel definitions in the sourcefile where it appears, but is opaque in nested
80+
An opaque type alias on the top-level is transparent in all other top-level definitions in the sourcefile where it appears, but is opaque in nested
8181
objects and classes and in all other source files. Example:
8282
```scala
8383
// in test1.scala
@@ -91,7 +91,7 @@ object obj {
9191
// in test2.scala
9292
def z: String = x // error: found: A, required: String
9393
```
94-
This behavior becomes clear if one recalls that toplevel definitions are placed in their own synthetic object. For instance, the code in `test1.scala` would expand to
94+
This behavior becomes clear if one recalls that top-level definitions are placed in their own synthetic object. For instance, the code in `test1.scala` would expand to
9595
```scala
9696
object test1$package {
9797
opaque type A = String

docs/docs/reference/other-new-features/transparent-traits.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ are treated automatically as transparent. Other traits are turned into transpare
4040
by adding a `@transparentTrait` annotation. This annotation is defined in `scala.annotation`. It will be deprecated and phased out once Scala 2/3 interopability is no longer needed.
4141

4242
Typically, transparent traits are traits
43-
that influence the implementation of inheriting classes and traits and that are not usually used as types by themselves. Two examples from the standard collection library:
43+
that influence the implementation of inheriting classes and traits that are not usually used as types by themselves. Two examples from the standard collection library:
4444

4545
- `IterableOps`, which provides method implementations for an `Iterable`
4646
- `StrictOptimizedSeqOps`, which optimises some of these implementations for

docs/docs/reference/overview.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ These constructs replace existing constructs with the aim of making the language
3939
- [Extension Methods](contextual/extension-methods.md) replace implicit classes with a clearer and simpler mechanism.
4040
- [Opaque type aliases](other-new-features/opaques.md) replace most uses
4141
of value classes while guaranteeing absence of boxing.
42-
- [Toplevel definitions](dropped-features/package-objects.md) replace package objects, dropping syntactic boilerplate.
42+
- [Top-level definitions](dropped-features/package-objects.md) replace package objects, dropping syntactic boilerplate.
4343
- [Export clauses](other-new-features/export.md)
4444
provide a simple and general way to express aggregation, which can replace the
4545
previous facade pattern of package objects inheriting from classes.

0 commit comments

Comments
 (0)