Skip to content

Commit bc1b6e3

Browse files
Daniel Parvinjskeet
authored andcommitted
Performed copyediting of the expressions document.
1 parent e68671f commit bc1b6e3

File tree

1 file changed

+23
-23
lines changed

1 file changed

+23
-23
lines changed

standard/expressions.md

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -156,9 +156,9 @@ The precedence of an operator is established by the definition of its associated
156156
> | [§12.12](expressions.md#1212-relational-and-type-testing-operators) | Equality | `==` `!=` |
157157
> | [§12.13](expressions.md#1213-logical-operators) | Logical AND | `&` |
158158
> | [§12.13](expressions.md#1213-logical-operators) | Logical XOR | `^` |
159-
> | [§12.13](expressions.md#1213-logical-operators) | Logical OR | `\|` |
159+
> | [§12.13](expressions.md#1213-logical-operators) | Logical OR | <code>&#124;</code> |
160160
> | [§12.14](expressions.md#1214-conditional-logical-operators) | Conditional AND | `&&` |
161-
> | [§12.14](expressions.md#1214-conditional-logical-operators) | Conditional OR | `\|\|` |
161+
> | [§12.14](expressions.md#1214-conditional-logical-operators) | Conditional OR | <code>&#124;&#124;</code> |
162162
> | [§12.15](expressions.md#1215-the-null-coalescing-operator) and12.16](expressions.md#1216-the-throw-expression-operator) | Null coalescing and throw expression | `??` `throw x` |
163163
> |12.18](expressions.md#1218-conditional-operator) | Conditional | `?:` |
164164
> |12.21](expressions.md#1221-assignment-operators) and12.19](expressions.md#1219-anonymous-function-expressions) | Assignment and lambda expression | `=` `= ref` `*=` `/=` `%=` `+=` `-=` `<<=` `>>=` `&=` `^=` `\|=` `=>` |
@@ -2348,7 +2348,7 @@ Use of `this` in a *primary_expression* in a context other than the ones listed
23482348

23492349
### 12.8.15 Base access
23502350

2351-
A *base_access* consists of the keyword base followed by either a “`.`” token and an identifier and optional *type_argument_list* or an *argument_list* enclosed in square brackets:
2351+
A *base_access* consists of the keyword `base` followed by either a “`.`” token and an identifier and optional *type_argument_list* or an *argument_list* enclosed in square brackets:
23522352

23532353
```ANTLR
23542354
base_access
@@ -2357,7 +2357,7 @@ base_access
23572357
;
23582358
```
23592359

2360-
A *base_access* is used to access base class members that are hidden by similarly named members in the current class or struct. A *base_access* is permitted only in the body of an instance constructor, an instance method, an instance accessor ([§12.2.1](expressions.md#1221-general)), or a finalizer. When `base.I` occurs in a class or struct, I shall denote a member of the base class of that class or struct. Likewise, when `base[E]` occurs in a class, an applicable indexer shall exist in the base class.
2360+
A *base_access* is used to access base class members that are hidden by similarly named members in the current class or struct. A *base_access* is permitted only in the body of an instance constructor, an instance method, an instance accessor ([§12.2.1](expressions.md#1221-general)), or a finalizer. When `base.I` occurs in a class or struct, `I` shall denote a member of the base class of that class or struct. Likewise, when `base[E]` occurs in a class, an applicable indexer shall exist in the base class.
23612361

23622362
At binding-time, *base_access* expressions of the form `base.I` and `base[E]` are evaluated exactly as if they were written `((B)this).I` and `((B)this)[E]`, where `B` is the base class of the class or struct in which the construct occurs. Thus, `base.I` and `base[E]` correspond to `this.I` and `this[E]`, except `this` is viewed as an instance of the base class.
23632363

@@ -2448,7 +2448,7 @@ Processing of an object creation expression that includes an object initializer
24482448

24492449
If any of the arguments in the optional *argument_list* has the compile-time type `dynamic` then the *object_creation_expression* is dynamically bound ([§12.3.3](expressions.md#1233-dynamic-binding)) and the following rules are applied at run-time using the run-time type of those arguments of the *argument_list* that have the compile-time type `dynamic`. However, the object creation undergoes a limited compile-time check as described in [§12.6.5](expressions.md#1265-compile-time-checking-of-dynamic-member-invocation).
24502450

2451-
The binding-time processing of an *object_creation_expression* of the form new `T(A)`, where `T` is a *class_type*, or a *value_type*, and `A` is an optional *argument_list*, consists of the following steps:
2451+
The binding-time processing of an *object_creation_expression* of the form `new T(A)`, where `T` is a *class_type*, or a *value_type*, and `A` is an optional *argument_list*, consists of the following steps:
24522452

24532453
- If `T` is a *value_type* and `A` is not present:
24542454
- The *object_creation_expression* is a default constructor invocation. The result of the *object_creation_expression* is a value of type `T`, namely the default value for `T` as defined in [§8.3.3](types.md#833-default-constructors).
@@ -2457,7 +2457,7 @@ The binding-time processing of an *object_creation_expression* of the form new `
24572457
- The result of the *object_creation_expression* is a value of the run-time type that the type parameter has been bound to, namely the result of invoking the default constructor of that type. The run-time type may be a reference type or a value type.
24582458
- Otherwise, if `T` is a *class_type* or a *struct_type*:
24592459
- If `T` is an abstract or static *class_type*, a compile-time error occurs.
2460-
- The instance constructor to invoke is determined using the overload resolution rules of [§12.6.4](expressions.md#1264-overload-resolution). The set of candidate instance constructors consists of all accessible instance constructors declared in `T`, which are applicable with respect to A ([§12.6.4.2](expressions.md#12642-applicable-function-member)). If the set of candidate instance constructors is empty, or if a single best instance constructor cannot be identified, a binding-time error occurs.
2460+
- The instance constructor to invoke is determined using the overload resolution rules of [§12.6.4](expressions.md#1264-overload-resolution). The set of candidate instance constructors consists of all accessible instance constructors declared in `T`, which are applicable with respect to `A` ([§12.6.4.2](expressions.md#12642-applicable-function-member)). If the set of candidate instance constructors is empty, or if a single best instance constructor cannot be identified, a binding-time error occurs.
24612461
- The result of the *object_creation_expression* is a value of type `T`, namely the value produced by invoking the instance constructor determined in the step above.
24622462
- Otherwise, the *object_creation_expression* is invalid, and a binding-time error occurs.
24632463

@@ -2661,7 +2661,8 @@ A collection initializer consists of a sequence of element initializers, enclose
26612661
26622662
The collection object to which a collection initializer is applied shall be of a type that implements `System.Collections.IEnumerable` or a compile-time error occurs. For each specified element in order from left to right, normal member lookup is applied to find a member named `Add`. If the result of the member lookup is not a method group, a compile-time error occurs. Otherwise, overload resolution is applied with the expression list of the element initializer as the argument list, and the collection initializer invokes the resulting method. Thus, the collection object shall contain an applicable instance or extension method with the name `Add` for each element initializer.
26632663
2664-
> *Example*:The following shows a class that represents a contact with a name and a list of phone numbers, and the creation and initialization of a `List<Contact>`:
2664+
> *Example*:
2665+
> The following shows a class that represents a contact with a name and a list of phone numbers, and the creation and initialization of a `List<Contact>`:
26652666
>
26662667
> <!-- Example: {template:"standalone-lib", name:"CollectionInitializers2"} -->
26672668
> ```csharp
@@ -3582,8 +3583,7 @@ The run-time processing of a prefix increment or decrement operation of the form
35823583
- If `x` is classified as a variable:
35833584
- `x` is evaluated to produce the variable.
35843585
- The value of `x` is converted to the operand type of the selected operator and the operator is invoked with this value as its argument.
3585-
- The value returned by the operator is converted to the type of `x`. The resulting value is stored in the location given by the evaluation of `x`.
3586-
- and becomes the result of the operation.
3586+
- The value returned by the operator is converted to the type of `x`. The resulting value is stored in the location given by the evaluation of `x` and becomes the result of the operation.
35873587
- If `x` is classified as a property or indexer access:
35883588
- The instance expression (if `x` is not `static`) and the argument list (if `x` is an indexer access) associated with `x` are evaluated, and the results are used in the subsequent get and set accessor invocations.
35893589
- The get accessor of `x` is invoked.
@@ -3747,7 +3747,7 @@ The predefined multiplication operators are listed below. The operators all comp
37473747
| **`-∞`** | `-∞` | `+∞` | `NaN` | `NaN` | `-∞` | `+∞` | `NaN` |
37483748
| **`NaN`** | `NaN` | `NaN` | `NaN` | `NaN` | `NaN` | `NaN` | `NaN` |
37493749

3750-
(Except were otherwise noted, in the floating-point tables in [§12.10.2](expressions.md#12102-multiplication-operator)[§12.10.6](expressions.md#12106-subtraction-operator) the use of “`+`” means the value is positive; the use of “`-`” means the value is negative; and the lack of a sign means the value may be positive or negative or has no sign (NaN).)
3750+
(Except where otherwise noted, in the floating-point tables in [§12.10.2](expressions.md#12102-multiplication-operator)[§12.10.6](expressions.md#12106-subtraction-operator) the use of “`+`” means the value is positive; the use of “`-`” means the value is negative; and the lack of a sign means the value may be positive or negative or has no sign (NaN).)
37513751
- Decimal multiplication:
37523752

37533753
```csharp
@@ -4458,7 +4458,7 @@ bool operator !=(System.Delegate x, System.Delegate y);
44584458
Two delegate instances are considered equal as follows:
44594459

44604460
- If either of the delegate instances is `null`, they are equal if and only if both are `null`.
4461-
- If the delegates have different run-time type, they are never equal.
4461+
- If the delegates have different run-time types, they are never equal.
44624462
- If both of the delegate instances have an invocation list ([§20.2](delegates.md#202-delegate-declarations)), those instances are equal if and only if their invocation lists are the same length, and each entry in one’s invocation list is equal (as defined below) to the corresponding entry, in order, in the other’s invocation list.
44634463

44644464
The following rules govern the equality of invocation list entries:
@@ -4529,7 +4529,7 @@ The *is-type operator* is used to check if the run-time type of an object is com
45294529

45304530
The operation is evaluated as follows:
45314531

4532-
1. If `E` is an anonymous function or method group, a compile-time error occurs
4532+
1. If `E` is an anonymous function or method group, a compile-time error occurs.
45334533
1. If `E` is the `null` literal, or if the value of `E` is `null`, the result is `false`.
45344534
1. Otherwise:
45354535
1. Let `R` be the runtime type of `E`.
@@ -4630,7 +4630,7 @@ Note that some conversions, such as user defined conversions, are not possible w
46304630
46314631
### 12.13.1 General
46324632
4633-
The `&,` `^`, and `|` operators are called the logical operators.
4633+
The `&`, `^`, and `|` operators are called the logical operators.
46344634
46354635
```ANTLR
46364636
and_expression
@@ -4816,7 +4816,7 @@ The type of the expression `a ?? b` depends on which implicit conversions are
48164816
- If `A` exists and is not a nullable value type or a reference type, a compile-time error occurs.
48174817
- Otherwise, if `A` exists and `b` is a dynamic expression, the result type is `dynamic`. At run-time, `a` is first evaluated. If `a` is not `null`, `a` is converted to `dynamic`, and this becomes the result. Otherwise, `b` is evaluated, and this becomes the result.
48184818
- Otherwise, if `A` exists and is a nullable value type and an implicit conversion exists from `b` to `A₀`, the result type is `A₀`. At run-time, `a` is first evaluated. If `a` is not `null`, `a` is unwrapped to type `A₀`, and this becomes the result. Otherwise, `b` is evaluated and converted to type `A₀`, and this becomes the result.
4819-
- Otherwise, if `A` exists and an implicit conversion exists from `b` to `A`, the result type is `A`. At run-time, a is first evaluated. If a is not null, a becomes the result. Otherwise, `b` is evaluated and converted to type `A`, and this becomes the result.
4819+
- Otherwise, if `A` exists and an implicit conversion exists from `b` to `A`, the result type is `A`. At run-time, `a` is first evaluated. If `a` is not `null`, `a` becomes the result. Otherwise, `b` is evaluated and converted to type `A`, and this becomes the result.
48204820
- Otherwise, if `A` exists and is a nullable value type, `b` has a type `B` and an implicit conversion exists from `A₀` to `B`, the result type is `B`. At run-time, `a` is first evaluated. If `a` is not `null`, `a` is unwrapped to type `A₀` and converted to type `B`, and this becomes the result. Otherwise, `b` is evaluated and becomes the result.
48214821
- Otherwise, if `b` has a type `B` and an implicit conversion exists from `a` to `B`, the result type is `B`. At run-time, `a` is first evaluated. If `a` is not `null`, `a` is converted to type `B`, and this becomes the result. Otherwise, `b` is evaluated and becomes the result.
48224822

@@ -5501,7 +5501,7 @@ class Test
55015501
}
55025502
```
55035503

5504-
This can be translated to a delegate instantiation that references a compiler generated static method in which the code of the anonymous function is placed:
5504+
This can be translated to a delegate instantiation that references a compiler-generated static method in which the code of the anonymous function is placed:
55055505

55065506
<!-- Example: {template:"standalone-lib", name:"AnonFunctionImplementationExample2"} -->
55075507
```csharp
@@ -5538,7 +5538,7 @@ class Test
55385538
}
55395539
```
55405540

5541-
This can be translated to a compiler generated instance method containing the code of the anonymous function:
5541+
This can be translated to a compiler-generated instance method containing the code of the anonymous function:
55425542

55435543
<!-- Example: {template:"standalone-lib", name:"AnonFunctionImplementationExample4", ignoredWarnings:["CS0649"]} -->
55445544
```csharp
@@ -5576,7 +5576,7 @@ class Test
55765576
}
55775577
```
55785578

5579-
The lifetime of the local variable must now be extended to at least the lifetime of the anonymous function delegate. This can be achieved by “hoisting” the local variable into a field of a compiler-generated class. Instantiation of the local variable ([§12.19.6.3](expressions.md#121963-instantiation-of-local-variables)) then corresponds to creating an instance of the compiler generated class, and accessing the local variable corresponds to accessing a field in the instance of the compiler generated class. Furthermore, the anonymous function becomes an instance method of the compiler-generated class:
5579+
The lifetime of the local variable must now be extended to at least the lifetime of the anonymous function delegate. This can be achieved by “hoisting” the local variable into a field of a compiler-generated class. Instantiation of the local variable ([§12.19.6.3](expressions.md#121963-instantiation-of-local-variables)) then corresponds to creating an instance of the compiler-generated class, and accessing the local variable corresponds to accessing a field in the instance of the compiler-generated class. Furthermore, the anonymous function becomes an instance method of the compiler-generated class:
55805580

55815581
<!-- Example: {template:"standalone-lib", name:"AnonFunctionImplementationExample6"} -->
55825582
```csharp
@@ -5625,7 +5625,7 @@ class Test
56255625
}
56265626
```
56275627

5628-
Here, a compiler-generated class is created for each block in which locals are captured such that the locals in the different blocks can have independent lifetimes. An instance of `__Locals2`, the compiler generated class for the inner block, contains the local variable `z` and a field that references an instance of `__Locals1`. An instance of `__Locals1`, the compiler generated class for the outer block, contains the local variable `y` and a field that references `this` of the enclosing function member. With these data structures, it is possible to reach all captured outer variables through an instance of `__Local2`, and the code of the anonymous function can thus be implemented as an instance method of that class.
5628+
Here, a compiler-generated class is created for each block in which locals are captured such that the locals in the different blocks can have independent lifetimes. An instance of `__Locals2`, the compiler-generated class for the inner block, contains the local variable `z` and a field that references an instance of `__Locals1`. An instance of `__Locals1`, the compiler-generated class for the outer block, contains the local variable `y` and a field that references `this` of the enclosing function member. With these data structures, it is possible to reach all captured outer variables through an instance of `__Local2`, and the code of the anonymous function can thus be implemented as an instance method of that class.
56295629

56305630
<!-- Example: {template:"standalone-lib", name:"AnonFunctionImplementationExample8", ignoredWarnings:["CS0649"]} -->
56315631
```csharp
@@ -5992,7 +5992,7 @@ Q
59925992
> Select(x => new { x.c.Name, x.o.OrderID, x.o.Total })
59935993
> ```
59945994
>
5995-
> where `x` is a compiler generated identifier that is otherwise invisible and inaccessible.
5995+
> where `x` is a compiler-generated identifier that is otherwise invisible and inaccessible.
59965996
>
59975997
> *end example*
59985998
@@ -6038,7 +6038,7 @@ from * in ( «e» ) . Select ( «x» => new { «x» , «y» = «f» } )
60386038
> .Select(x => new { x.o.OrderID, Total = x.t })
60396039
> ```
60406040
>
6041-
> where `x` is a compiler generated identifier that is otherwise invisible and inaccessible.
6041+
> where `x` is a compiler-generated identifier that is otherwise invisible and inaccessible.
60426042
>
60436043
> *end example*
60446044
@@ -6074,7 +6074,7 @@ is translated into
60746074
> *Example*: The example
60756075
>
60766076
> ```csharp
6077-
> from c in customersh
6077+
> from c in customers
60786078
> join o in orders on c.CustomerID equals o.CustomerID
60796079
> select new { c.Name, o.OrderDate, o.Total }
60806080
> ```
@@ -6175,7 +6175,7 @@ from * in ( «e1» ) . GroupJoin(
61756175
> .Select(y => new { y.x.c.Name, OrderCount = y.n })
61766176
> ```
61776177
>
6178-
> where `x` and `y` are compiler generated identifiers that are otherwise invisible and inaccessible.
6178+
> where `x` and `y` are compiler-generated identifiers that are otherwise invisible and inaccessible.
61796179
>
61806180
> *end example*
61816181
@@ -6337,7 +6337,7 @@ In the translation steps described above, transparent identifiers are always int
63376337
> .Select(x => new { x.c.Name, x.o.Total })
63386338
> ```
63396339
>
6340-
> where `x` is a compiler generated identifier that is otherwise invisible and inaccessible.
6340+
> where `x` is a compiler-generated identifier that is otherwise invisible and inaccessible.
63416341
>
63426342
> The example
63436343
>

0 commit comments

Comments
 (0)