Skip to content

Commit 02d7b26

Browse files
authored
Remove references to pointers within the standard where appropriate. (#678)
- They're still present in the grammar, and in explanatory paragraphs after relevant grammar sections. - There are references in Annexes B and D, but that feels reasonable. Fixes #676.
1 parent 98e9bd4 commit 02d7b26

File tree

5 files changed

+13
-10
lines changed

5 files changed

+13
-10
lines changed

standard/classes.md

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ A *primary_expression* ([§11.7](expressions.md#117-primary-expressions)) is per
140140
141141
In any other context, it is a compile-time error to reference a static class.
142142
143-
> *Note*: For example, it is an error for a static class to be used as a base class, a constituent type ([§14.3.7](classes.md#1437-constituent-types)) of a member, a generic type argument, or a type parameter constraint. Likewise, a static class cannot be used in an array type, a pointer type, a new expression, a cast expression, an is expression, an as expression, a `sizeof` expression, or a default value expression. *end note*
143+
> *Note*: For example, it is an error for a static class to be used as a base class, a constituent type ([§14.3.7](classes.md#1437-constituent-types)) of a member, a generic type argument, or a type parameter constraint. Likewise, a static class cannot be used in an array type, a new expression, a cast expression, an is expression, an as expression, a `sizeof` expression, or a default value expression. *end note*
144144
145145
### 14.2.3 Type parameters
146146
@@ -441,8 +441,6 @@ The value type constraint specifies that a type argument used for the type param
441441

442442
> *Note*: The `System.Nullable<T>` type specifies the non-nullable value type constraint for `T`. Thus, recursively constructed types of the forms `T??` and `Nullable<Nullable<T>>` are prohibited. *end note*
443443
444-
Pointer types are never allowed to be type arguments and are not considered to satisfy either the reference type or value type constraints.
445-
446444
If a constraint is a class type, an interface type, or a type parameter, that type specifies a minimal “base type” that every type argument used for that type parameter shall support. Whenever a constructed type or generic method is used, the type argument is checked against the constraints on the type parameter at compile-time. The type argument supplied shall satisfy the conditions described in [§8.4.5](types.md#845-satisfying-constraints).
447445

448446
A *class_type* constraint shall satisfy the following rules:
@@ -566,7 +564,6 @@ The ***dynamic erasure*** of a type `C` is type `Cₓ` constructed as follows:
566564
- If `C` is a nested type `Outer.Inner` then `Cₓ` is a nested type `Outerₓ.Innerₓ`.
567565
- If `C` `Cₓ`is a constructed type `G<A¹, ..., A>` with type arguments `A¹, ..., Aⁿ` then `Cₓ` is the constructed type `G<A¹ₓ, ..., Aⁿₓ>`.
568566
- If `C` is an array type `E[]` then `Cₓ` is the array type `Eₓ[]`.
569-
- If `C` is a pointer type `E*` then `Cₓ` is the pointer type `Eₓ*`.
570567
- If `C` is dynamic then `Cₓ` is `object`.
571568
- Otherwise, `Cₓ` is `C`.
572569
@@ -2915,7 +2912,7 @@ class Customer
29152912
29162913
### 14.6.10 Extension methods
29172914
2918-
When the first parameter of a method includes the `this` modifier, that method is said to be an ***extension method***. Extension methods shall only be declared in non-generic, non-nested static classes. The first parameter of an extension method may have no modifiers other than `this`, and the parameter type may not be a pointer type.
2915+
When the first parameter of a method includes the `this` modifier, that method is said to be an ***extension method***. Extension methods shall only be declared in non-generic, non-nested static classes. The first parameter of an extension method may have no modifiers other than `this`.
29192916
29202917
> *Example*: The following is an example of a static class that declares two extension methods:
29212918
>

standard/expressions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2598,7 +2598,7 @@ class __Anonymous1
25982598
}
25992599
```
26002600

2601-
where each «Tx» is the type of the corresponding expression «ex». The expression used in a *member_declarator* shall have a type. Thus, it is a compile-time error for an expression in a *member_declarator* to be `null` or an anonymous function. It is also a compile-time error for the expression to have a pointer type ([§22.3](unsafe-code.md#223-pointer-types)).
2601+
where each «Tx» is the type of the corresponding expression «ex». The expression used in a *member_declarator* shall have a type. Thus, it is a compile-time error for an expression in a *member_declarator* to be `null` or an anonymous function.
26022602

26032603
The names of an anonymous type and of the parameter to its `Equals` method are automatically generated by the compiler and cannot be referenced in program text.
26042604

standard/types.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,7 @@ type_argument
481481
;
482482
```
483483
484-
A *type_argument* shall not be a pointer type ([§22](unsafe-code.md#22-unsafe-code)). Each type argument shall satisfy any constraints on the corresponding type parameter ([§14.2.5](classes.md#1425-type-parameter-constraints)).
484+
Each type argument shall satisfy any constraints on the corresponding type parameter ([§14.2.5](classes.md#1425-type-parameter-constraints)).
485485
486486
### 8.4.3 Open and closed types
487487
@@ -650,4 +650,3 @@ An *unmanaged_type* is any type that isn’t a *reference_type*, a *type_paramet
650650
- `sbyte`, `byte`, `short`, `ushort`, `int`, `uint`, `long`, `ulong`, `char`, `float`, `double`, `decimal`, or `bool`.
651651
- Any *enum_type*.
652652
- Any user-defined *struct_type* that is not a constructed type and contains fields of *unmanaged_type*s only.
653-
- In unsafe code ([§22.2](unsafe-code.md#222-unsafe-contexts)), any *pointer_type* ([§22.3](unsafe-code.md#223-pointer-types)).

standard/unsafe-code.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ The type specified before the `*` in a pointer type is called the ***referent ty
130130

131131
A *pointer_type* may only be used in an *array_type* in an unsafe context ([§22.2](unsafe-code.md#222-unsafe-contexts)). A *non_array_type* is any type that is not itself an *array_type*.
132132

133-
Unlike references (values of reference types), pointers are not tracked by the garbage collector—the garbage collector has no knowledge of pointers and the data to which they point. For this reason a pointer is not permitted to point to a reference or to a struct that contains references, and the referent type of a pointer shall be an *unmanaged_type*.
133+
Unlike references (values of reference types), pointers are not tracked by the garbage collector—the garbage collector has no knowledge of pointers and the data to which they point. For this reason a pointer is not permitted to point to a reference or to a struct that contains references, and the referent type of a pointer shall be an *unmanaged_type*. Pointer types themselves are unmanaged types, so a pointer type may be used as the referent type for another pointer type.
134134

135135
The intuitive rule for mixing of pointers and references is that referents of references (objects) are permitted to contain pointers, but referents of pointers are not permitted to contain references.
136136

@@ -170,8 +170,16 @@ A *pointer_type* cannot be used as a type argument ([§8.4](types.md#84-construc
170170
171171
A *pointer_type* cannot be used as a type of a subexpression of a dynamically bound operation ([§11.3.3](expressions.md#1133-dynamic-binding)).
172172
173+
A *pointer_type* cannot be used as the type of the first parameter in an extension method ([§14.6.10](classes.md#14610-extension-methods)).
174+
173175
A *pointer_type* may be used as the type of a volatile field ([§14.5.4](classes.md#1454-volatile-fields)).
174176
177+
The *dynamic erasure* of a type `E*` is the pointer type with referent type of the dynamic erasure of `E`.
178+
179+
An expression with a pointer type cannot be used to provide the value in a *member_declarator* within an *anonymous_object_creation_expression* ([§11.7.15.7](expressions.md#117157-anonymous-object-creation-expressions)).
180+
181+
The default value ([§9.3](variables.md#93-default-values)) for any pointer type is `null`.
182+
175183
> *Note*: Although pointers can be passed as `ref` or `out` parameters, doing so can cause undefined behavior, since the pointer might well be set to point to a local variable that no longer exists when the called method returns, or the fixed object to which it used to point, is no longer fixed. For example:
176184
>
177185
> <!-- Example: {template:"standalone-console-without-using", name:"PointerTypes1", replaceEllipsis:true} -->

standard/variables.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,6 @@ The default value of a variable depends on the type of the variable and is deter
162162
163163
- For a variable of a *value_type*, the default value is the same as the value computed by the *value_type*’s default constructor ([§8.3.3](types.md#833-default-constructors)).
164164
- For a variable of a *reference_type*, the default value is `null`.
165-
- In an unsafe context, for a variable of a *pointer_type*, the default value is `null`.
166165
167166
> *Note*: Initialization to default values is typically done by having the memory manager or garbage collector initialize memory to all-bits-zero before it is allocated for use. For this reason, it is convenient to use all-bits-zero to represent the null reference. *end note*
168167

0 commit comments

Comments
 (0)