From 56290590067955f207b7a5ddab8190293e30b697 Mon Sep 17 00:00:00 2001 From: Julien Couvreur Date: Mon, 18 Apr 2022 22:10:20 -0700 Subject: [PATCH 01/18] Spec out numeric IntPtr --- proposals/numeric-intptr.md | 283 ++++++++++++++++++++++++++++++++++++ 1 file changed, 283 insertions(+) create mode 100644 proposals/numeric-intptr.md diff --git a/proposals/numeric-intptr.md b/proposals/numeric-intptr.md new file mode 100644 index 0000000000..8a06453d67 --- /dev/null +++ b/proposals/numeric-intptr.md @@ -0,0 +1,283 @@ + +TODO minus operator +TODO pointer arithmetic +TODO dynamic +TODO Possible breaking changes: IntPtr + int, IntPtr - int, (int)IntPtr, (IntPtr)long (and then of course various possible edge cases where user-defined vs language-defined operators subtly differ in behavior) + + + +### 8.3.5 Simple types +https://github.com/dotnet/csharpstandard/blob/draft-v7/standard/types.md#835-simple-types + +**Keyword** | **Aliased type** +----------- | ------------------ + `sbyte` | `System.SByte` + `byte` | `System.Byte` + `short` | `System.Int16` + `ushort` | `System.UInt16` + `int` | `System.Int32` + `uint` | `System.UInt32` + **`nint`** | **`System.IntPtr`** + **`nuint`** | **`System.UIntPtr`** + `long` | `System.Int64` + `ulong` | `System.UInt64` + `char` | `System.Char` + `float` | `System.Single` + `double` | `System.Double` + `bool` | `System.Boolean` + `decimal` | `System.Decimal` + +### 8.3.6 Integral types +Integral types: https://github.com/dotnet/csharpstandard/blob/draft-v7/standard/types.md#836-integral-types +C# supports **eleven** integral types: `sbyte`, `byte`, `short`, `ushort`, `int`, `uint`, **`nint`, `nuint`**, `long`, `ulong`, and `char`. The integral types have the following sizes and ranges of values: +... +- **The int type represents signed 32-bit integers with values from -2147483648 to 2147483647, inclusive.** TODO2 for nint and nuint + +## 8.8 Unmanaged types +Unmanaged types: https://github.com/dotnet/csharpstandard/blob/draft-v7/standard/types.md#88-unmanaged-types +In other words, an __unmanaged_type__ is one of the following: +- `sbyte`, `byte`, `short`, `ushort`, `int`, `uint`, **`nint`, `nuint`**, `long`, `ulong`, `char`, `float`, `double`, `decimal`, or `bool`. +- Any *enum_type*. +- Any user-defined *struct_type* that is not a constructed type and contains fields of *unmanaged_type*s only. +- In unsafe code, any *pointer_type*. + +### 10.2.3 Implicit numeric conversions + + +The implicit numeric conversions are: +... + +### 10.2.11 Implicit constant expression conversions + +An implicit constant expression conversion permits the following conversions: + +- A *constant_expression* of type `int` can be converted to type `sbyte`, `byte`, `short`, `ushort`, `uint`, **`nint`, `nuint`**, or `ulong`, provided the value of the *constant_expression* is within the range of the destination type. +... + + +### 10.3.3 Explicit enumeration conversions + +TODO +The explicit enumeration conversions are: + +- From `sbyte`, `byte`, `short`, `ushort`, `int`, `uint`, `long`, `ulong`, `char`, `float`, `double`, or `decimal` to any *enum_type*. +- From any *enum_type* to `sbyte`, `byte`, `short`, `ushort`, `int`, `uint`, `long`, `ulong`, `char`, `float`, `double`, or `decimal`. +- From any *enum_type* to any other *enum_type*. + + +Unary operators: https://github.com/dotnet/csharpstandard/blob/draft-v7/standard/expressions.md#118-unary-operators +### 11.8.2 Unary plus operator +https://github.com/dotnet/csharpstandard/blob/draft-v7/standard/expressions.md#1182-unary-plus-operator +The predefined unary plus operators are: + +```csharp +... +nint operator +(nint x); +nuint operator +(nuint x); +``` + +# 11 Expressions + +### 11.7.10 Element access + +\[...] The number of expressions in the *argument_list* shall be the same as the rank of the *array_type*, and each expression shall be of type `int`, `uint`, **`nint`, `nuint`**, `long`, or `ulong,` or shall be implicitly convertible to one or more of these types. + +#### 11.7.10.2 Array access + +### 11.7.14 Postfix increment and decrement operators + +Unary operator overload resolution is applied to select a specific operator implementation. Predefined `++` and `--` operators exist for the following types: `sbyte`, `byte`, `short`, `ushort`, `int`, `uint`, **`nint*, `nuint`**, `long`, `ulong`, `char`, `float`, `double`, `decimal`, and any enum type. + + +### 11.8.3 Unary minus operator +https://github.com/dotnet/csharpstandard/blob/draft-v7/standard/expressions.md#1183-unary-minus-operator + +The predefined unary minus operators are: + +- Integer negation: + + ```csharp + ... + nint operator –(nint x); + ``` + + The result is computed by ... TODO2 + +### 11.7.14 Postfix increment and decrement operators + +Predefined `++` and `--` operators exist for the following types: `sbyte`, `byte`, `short`, `ushort`, `int`, `uint`, **`nint`, `nuint`**, `long`, `ulong`, `char`, `float`, `double`, `decimal`, and any enum type. + +### 11.7.19 Default value expressions + +In addition, a *default_value_expression* is a constant expression if the type is one of the following value types: `sbyte`, `byte`, `short`, `ushort`, `int`, `uint`, **`nint`, `nuint`**, `long`, `ulong`, `char`, `float`, `double`, `decimal`, `bool,` or any enumeration type. + + +### 11.8.5 Bitwise complement operator +https://github.com/dotnet/csharpstandard/blob/draft-v7/standard/expressions.md#1185-bitwise-complement-operator + +The predefined bitwise complement operators are: + +```csharp +... +nint operator ~(nint x); +nuint operator ~(nuint x); +``` + +### 11.8.6 Prefix increment and decrement operators + +Predefined `++` and `--` operators exist for the following types: `sbyte`, `byte`, `short`, `ushort`, `int`, `uint`, **`nint`, `nuint`**, `long`, `ulong`, `char`, `float`, `double`, `decimal`, and any enum type. + +## 11.9 Arithmetic operators + +### 11.9.2 Multiplication operator + +The predefined multiplication operators are listed below. The operators all compute the product of `x` and `y`. + + +- Integer multiplication: + + ```csharp + ... + nint operator *(nint x, nint y); + nuint operator *(nuint x, nuint y); + ``` + +### 11.9.3 Division operator + +The predefined division operators are listed below. The operators all compute the quotient of `x` and `y`. + +- Integer division: + + ```csharp + ... + nint operator /(nint x, nint y); + nuint operator /(nuint x, nuint y); + ``` + +### 11.9.4 Remainder operator + +The predefined remainder operators are listed below. The operators all compute the remainder of the division between `x` and `y`. + +- Integer remainder: + + ```csharp + ... + nint operator %(nint x, nint y); + nuint operator %(nuint x, nuint y); + ``` + +### 11.9.5 Addition operator + + +- Integer addition: + + ```csharp + ... + nint operator +(nint x, nint y); + nuint operator +(nuint x, nuint y); + ``` + +### 11.9.6 Subtraction operator + +- Integer subtraction: + + ```csharp + ... + nint operator –(nint x, nint y); + nuint operator –(nuint x, nuint y); + ``` + +## 11.10 Shift operators + +The predefined shift operators are listed below. + +- Shift left: + + ```csharp + ... + nint operator <<(nint x, nint count); + nuint operator <<(nuint x, nint count); + ``` + +- Shift right: + + ```csharp + ... + nint operator >>(nint x, nint count); + nuint operator >>(nuint x, nint count); + ``` + + The `>>` operator shifts `x` right by a number of bits computed as described below. + + When `x` is of type `int`, **`nint`** or `long`, the low-order bits of `x` are discarded, the remaining bits are shifted right, and the high-order empty bit positions are set to zero if `x` is non-negative and set to one if `x` is negative. + + When `x` is of type `uint`, **`nuint`** or `ulong`, the low-order bits of `x` are discarded, the remaining bits are shifted right, and the high-order empty bit positions are set to zero. + +For the predefined operators, the number of bits to shift is computed as follows: + +- When the type of `x` is `int`, **`nint`** or `uint`, the shift count is given by the low-order five bits of `count`. In other words, the shift count is computed from `count & 0x1F`. +- When the type of `x` is `long`, **`nuint`** or `ulong`, the shift count is given by the low-order six bits of `count`. In other words, the shift count is computed from `count & 0x3F`. + +- Unsigned shift right: + + ```csharp + ... + nint operator >>>(nint x, nint count); + nuint operator >>>(nuint x, nint count); + ``` + +## 11.11 Relational and type-testing operators + + +### 11.11.2 Integer comparison operators + +The predefined integer comparison operators are: + +```csharp +... +bool operator ==(nint x, nint y); +bool operator ==(nuint x, nuint y); + +bool operator !=(nint x, nint y); +bool operator !=(nuint x, nuint y); + +bool operator <(nint x, nint y); +bool operator <(nuint x, nuint y); + +bool operator >(nint x, nint y); +bool operator >(nuint x, nuint y); + +bool operator <=(nint x, nint y); +bool operator <=(nuint x, nuint y); + +bool operator >=(nint x, nint y); +bool operator >=(nuint x, nuint y); +``` + +## 11.12 Logical operators + +### 11.12.2 Integer logical operators + + +The predefined integer logical operators are: + +```csharp +... +nint operator &(nint x, nint y); +nuint operator &(nuint x, nuint y); + +nint operator |(nint x, nint y); +nuint operator |(nuint x, nuint y); + +nint operator ^(nint x, nint y); +nuint operator ^(nuint x, nuint y); +``` + +## 11.20 Constant expressions + +A constant expression may be either a value type or a reference type. If a constant expression is a value type, it must be one of the following types: `sbyte`, `byte`, `short`, `ushort`, `int`, `uint`, **`nint`, `nuint`**, `long`, `ulong`, `char`, `float`, `double`, `decimal`, `bool,` or any enumeration type. + +\[...] + + +An implicit constant expression conversion permits a constant expression of type `int` to be converted to `sbyte`, `byte`, `short`, `ushort`, `nint`, `uint`, `nuint`, or `ulong`, provided the value of the constant expression is within the range of the destination type. From 8430228f7cc2aad795104a81cb8c7f5f240fcd6f Mon Sep 17 00:00:00 2001 From: Julien Couvreur Date: Tue, 19 Apr 2022 10:00:14 -0700 Subject: [PATCH 02/18] tweak --- proposals/numeric-intptr.md | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/proposals/numeric-intptr.md b/proposals/numeric-intptr.md index 8a06453d67..3be3628d53 100644 --- a/proposals/numeric-intptr.md +++ b/proposals/numeric-intptr.md @@ -4,8 +4,6 @@ TODO pointer arithmetic TODO dynamic TODO Possible breaking changes: IntPtr + int, IntPtr - int, (int)IntPtr, (IntPtr)long (and then of course various possible edge cases where user-defined vs language-defined operators subtly differ in behavior) - - ### 8.3.5 Simple types https://github.com/dotnet/csharpstandard/blob/draft-v7/standard/types.md#835-simple-types @@ -43,7 +41,6 @@ In other words, an __unmanaged_type__ is one of the following: ### 10.2.3 Implicit numeric conversions - The implicit numeric conversions are: ... @@ -54,7 +51,6 @@ An implicit constant expression conversion permits the following conversions: - A *constant_expression* of type `int` can be converted to type `sbyte`, `byte`, `short`, `ushort`, `uint`, **`nint`, `nuint`**, or `ulong`, provided the value of the *constant_expression* is within the range of the destination type. ... - ### 10.3.3 Explicit enumeration conversions TODO @@ -64,7 +60,6 @@ The explicit enumeration conversions are: - From any *enum_type* to `sbyte`, `byte`, `short`, `ushort`, `int`, `uint`, `long`, `ulong`, `char`, `float`, `double`, or `decimal`. - From any *enum_type* to any other *enum_type*. - Unary operators: https://github.com/dotnet/csharpstandard/blob/draft-v7/standard/expressions.md#118-unary-operators ### 11.8.2 Unary plus operator https://github.com/dotnet/csharpstandard/blob/draft-v7/standard/expressions.md#1182-unary-plus-operator @@ -88,7 +83,6 @@ nuint operator +(nuint x); Unary operator overload resolution is applied to select a specific operator implementation. Predefined `++` and `--` operators exist for the following types: `sbyte`, `byte`, `short`, `ushort`, `int`, `uint`, **`nint*, `nuint`**, `long`, `ulong`, `char`, `float`, `double`, `decimal`, and any enum type. - ### 11.8.3 Unary minus operator https://github.com/dotnet/csharpstandard/blob/draft-v7/standard/expressions.md#1183-unary-minus-operator @@ -111,7 +105,6 @@ Predefined `++` and `--` operators exist for the following types: `sbyte`, `byte In addition, a *default_value_expression* is a constant expression if the type is one of the following value types: `sbyte`, `byte`, `short`, `ushort`, `int`, `uint`, **`nint`, `nuint`**, `long`, `ulong`, `char`, `float`, `double`, `decimal`, `bool,` or any enumeration type. - ### 11.8.5 Bitwise complement operator https://github.com/dotnet/csharpstandard/blob/draft-v7/standard/expressions.md#1185-bitwise-complement-operator @@ -133,7 +126,6 @@ Predefined `++` and `--` operators exist for the following types: `sbyte`, `byte The predefined multiplication operators are listed below. The operators all compute the product of `x` and `y`. - - Integer multiplication: ```csharp @@ -168,7 +160,6 @@ The predefined remainder operators are listed below. The operators all compute t ### 11.9.5 Addition operator - - Integer addition: ```csharp @@ -213,11 +204,6 @@ The predefined shift operators are listed below. When `x` is of type `uint`, **`nuint`** or `ulong`, the low-order bits of `x` are discarded, the remaining bits are shifted right, and the high-order empty bit positions are set to zero. -For the predefined operators, the number of bits to shift is computed as follows: - -- When the type of `x` is `int`, **`nint`** or `uint`, the shift count is given by the low-order five bits of `count`. In other words, the shift count is computed from `count & 0x1F`. -- When the type of `x` is `long`, **`nuint`** or `ulong`, the shift count is given by the low-order six bits of `count`. In other words, the shift count is computed from `count & 0x3F`. - - Unsigned shift right: ```csharp @@ -228,7 +214,6 @@ For the predefined operators, the number of bits to shift is computed as follows ## 11.11 Relational and type-testing operators - ### 11.11.2 Integer comparison operators The predefined integer comparison operators are: @@ -258,7 +243,6 @@ bool operator >=(nuint x, nuint y); ### 11.12.2 Integer logical operators - The predefined integer logical operators are: ```csharp @@ -279,5 +263,4 @@ A constant expression may be either a value type or a reference type. If a const \[...] - An implicit constant expression conversion permits a constant expression of type `int` to be converted to `sbyte`, `byte`, `short`, `ushort`, `nint`, `uint`, `nuint`, or `ulong`, provided the value of the constant expression is within the range of the destination type. From 4120807403fcfde847b2d7c3db973c6c94e35b77 Mon Sep 17 00:00:00 2001 From: Julien Couvreur Date: Tue, 19 Apr 2022 10:05:50 -0700 Subject: [PATCH 03/18] Add intro --- proposals/numeric-intptr.md | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/proposals/numeric-intptr.md b/proposals/numeric-intptr.md index 3be3628d53..492f93f5dd 100644 --- a/proposals/numeric-intptr.md +++ b/proposals/numeric-intptr.md @@ -1,9 +1,18 @@ +# Numeric IntPtr -TODO minus operator TODO pointer arithmetic TODO dynamic TODO Possible breaking changes: IntPtr + int, IntPtr - int, (int)IntPtr, (IntPtr)long (and then of course various possible edge cases where user-defined vs language-defined operators subtly differ in behavior) +## Summary +[summary]: #summary + +This is a revision on the initial native integers feature ([spec](https://github.com/dotnet/csharplang/blob/main/proposals/csharp-9.0/native-integers.md)), where the `nint`/`nuint` types were distinct from the underlying types `System.IntPtr`/`System.UIntPtr`. +In short, we now treat `nint`/`nuint` as simple types aliasing `System.IntPtr`/`System.UIntPtr`, like we do for `int` in relation to `System.Int32`. + +## Design +[design]: #design + ### 8.3.5 Simple types https://github.com/dotnet/csharpstandard/blob/draft-v7/standard/types.md#835-simple-types From dde21b3f28ed0dbc02285990d1dc96138b9d8f99 Mon Sep 17 00:00:00 2001 From: Julien Couvreur Date: Wed, 20 Apr 2022 08:02:14 -0700 Subject: [PATCH 04/18] typo --- proposals/numeric-intptr.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/proposals/numeric-intptr.md b/proposals/numeric-intptr.md index 492f93f5dd..97875e3d2e 100644 --- a/proposals/numeric-intptr.md +++ b/proposals/numeric-intptr.md @@ -195,8 +195,8 @@ The predefined shift operators are listed below. ```csharp ... - nint operator <<(nint x, nint count); - nuint operator <<(nuint x, nint count); + nint operator <<(nint x, int count); + nuint operator <<(nuint x, int count); ``` - Shift right: From 2a5419b04ec77aedac95ef84aee992f9a64c9555 Mon Sep 17 00:00:00 2001 From: Julien Couvreur Date: Mon, 25 Apr 2022 14:26:22 -0700 Subject: [PATCH 05/18] tweak --- proposals/numeric-intptr.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/proposals/numeric-intptr.md b/proposals/numeric-intptr.md index 97875e3d2e..fc499fae95 100644 --- a/proposals/numeric-intptr.md +++ b/proposals/numeric-intptr.md @@ -3,6 +3,8 @@ TODO pointer arithmetic TODO dynamic TODO Possible breaking changes: IntPtr + int, IntPtr - int, (int)IntPtr, (IntPtr)long (and then of course various possible edge cases where user-defined vs language-defined operators subtly differ in behavior) +TODO Call out behavior with operators defined on IntPtr/UIntPtr +TODO Conversion to/from enumeration ## Summary [summary]: #summary From 5395f96de5c71df908a91c4c8eb75b73669b2943 Mon Sep 17 00:00:00 2001 From: Julien Couvreur Date: Mon, 25 Apr 2022 20:31:22 -0700 Subject: [PATCH 06/18] Add more details on conversion --- proposals/numeric-intptr.md | 48 ++++++++++++++++++++++++++++++------- 1 file changed, 40 insertions(+), 8 deletions(-) diff --git a/proposals/numeric-intptr.md b/proposals/numeric-intptr.md index fc499fae95..ff6aae5683 100644 --- a/proposals/numeric-intptr.md +++ b/proposals/numeric-intptr.md @@ -37,13 +37,13 @@ https://github.com/dotnet/csharpstandard/blob/draft-v7/standard/types.md#835-sim `decimal` | `System.Decimal` ### 8.3.6 Integral types -Integral types: https://github.com/dotnet/csharpstandard/blob/draft-v7/standard/types.md#836-integral-types + C# supports **eleven** integral types: `sbyte`, `byte`, `short`, `ushort`, `int`, `uint`, **`nint`, `nuint`**, `long`, `ulong`, and `char`. The integral types have the following sizes and ranges of values: ... - **The int type represents signed 32-bit integers with values from -2147483648 to 2147483647, inclusive.** TODO2 for nint and nuint ## 8.8 Unmanaged types -Unmanaged types: https://github.com/dotnet/csharpstandard/blob/draft-v7/standard/types.md#88-unmanaged-types + In other words, an __unmanaged_type__ is one of the following: - `sbyte`, `byte`, `short`, `ushort`, `int`, `uint`, **`nint`, `nuint`**, `long`, `ulong`, `char`, `float`, `double`, `decimal`, or `bool`. - Any *enum_type*. @@ -53,14 +53,49 @@ In other words, an __unmanaged_type__ is one of the following: ### 10.2.3 Implicit numeric conversions The implicit numeric conversions are: -... +TODO2 + +- From `sbyte` to `short`, `int`, `long`, `float`, `double`, or `decimal`. +- From `byte` to `short`, `ushort`, `int`, `uint`, `long`, `ulong`, `float`, `double`, or `decimal`. +- From `short` to `int`, `long`, `float`, `double`, or `decimal`. +- From `ushort` to `int`, `uint`, `long`, `ulong`, `float`, `double`, or `decimal`. +- From `int` to `long`, `float`, `double`, or `decimal`. +- From `uint` to `long`, `ulong`, `float`, `double`, or `decimal`. +- From `long` to `float`, `double`, or `decimal`. +- From `ulong` to `float`, `double`, or `decimal`. +- From `char` to `ushort`, `int`, `uint`, `long`, `ulong`, `float`, `double`, or `decimal`. +- From `float` to `double`. + +Conversions from `int`, `uint`, `long` or `ulong` to `float` and from `long` or `ulong` to `double` may cause a loss of precision, but will never cause a loss of magnitude. The other implicit numeric conversions never lose any information. + +\[...] ### 10.2.11 Implicit constant expression conversions An implicit constant expression conversion permits the following conversions: - A *constant_expression* of type `int` can be converted to type `sbyte`, `byte`, `short`, `ushort`, `uint`, **`nint`, `nuint`**, or `ulong`, provided the value of the *constant_expression* is within the range of the destination type. -... +\[...] + +### 10.3.2 Explicit numeric conversions + +The explicit numeric conversions are the conversions from a *numeric_type* to another *numeric_type* for which an implicit numeric conversion does not already exist: + +TODO2 +- From `sbyte` to `byte`, `ushort`, `uint`, `ulong`, or `char`. +- From `byte` to `sbyte` or `char`. +- From `short` to `sbyte`, `byte`, `ushort`, `uint`, `ulong`, or `char`. +- From `ushort` to `sbyte`, `byte`, `short`, or `char`. +- From `int` to `sbyte`, `byte`, `short`, `ushort`, `uint`, `ulong`, or `char`. +- From `uint` to `sbyte`, `byte`, `short`, `ushort`, `int`, or `char`. +- From `long` to `sbyte`, `byte`, `short`, `ushort`, `int`, `uint`, `ulong`, or `char`. +- From `ulong` to `sbyte`, `byte`, `short`, `ushort`, `int`, `uint`, `long`, or `char`. +- From `char` to `sbyte`, `byte`, or `short`. +- From `float` to `sbyte`, `byte`, `short`, `ushort`, `int`, `uint`, `long`, `ulong`, `char`, or `decimal`. +- From `double` to `sbyte`, `byte`, `short`, `ushort`, `int`, `uint`, `long`, `ulong`, `char`, `float`, or `decimal`. +- From `decimal` to `sbyte`, `byte`, `short`, `ushort`, `int`, `uint`, `long`, `ulong`, `char`, `float`, or `double`. + +\[...] ### 10.3.3 Explicit enumeration conversions @@ -71,9 +106,8 @@ The explicit enumeration conversions are: - From any *enum_type* to `sbyte`, `byte`, `short`, `ushort`, `int`, `uint`, `long`, `ulong`, `char`, `float`, `double`, or `decimal`. - From any *enum_type* to any other *enum_type*. -Unary operators: https://github.com/dotnet/csharpstandard/blob/draft-v7/standard/expressions.md#118-unary-operators ### 11.8.2 Unary plus operator -https://github.com/dotnet/csharpstandard/blob/draft-v7/standard/expressions.md#1182-unary-plus-operator + The predefined unary plus operators are: ```csharp @@ -95,7 +129,6 @@ nuint operator +(nuint x); Unary operator overload resolution is applied to select a specific operator implementation. Predefined `++` and `--` operators exist for the following types: `sbyte`, `byte`, `short`, `ushort`, `int`, `uint`, **`nint*, `nuint`**, `long`, `ulong`, `char`, `float`, `double`, `decimal`, and any enum type. ### 11.8.3 Unary minus operator -https://github.com/dotnet/csharpstandard/blob/draft-v7/standard/expressions.md#1183-unary-minus-operator The predefined unary minus operators are: @@ -117,7 +150,6 @@ Predefined `++` and `--` operators exist for the following types: `sbyte`, `byte In addition, a *default_value_expression* is a constant expression if the type is one of the following value types: `sbyte`, `byte`, `short`, `ushort`, `int`, `uint`, **`nint`, `nuint`**, `long`, `ulong`, `char`, `float`, `double`, `decimal`, `bool,` or any enumeration type. ### 11.8.5 Bitwise complement operator -https://github.com/dotnet/csharpstandard/blob/draft-v7/standard/expressions.md#1185-bitwise-complement-operator The predefined bitwise complement operators are: From 1e23b4f9a75c0ad45518b9fc8f8e57290b2ad19e Mon Sep 17 00:00:00 2001 From: Julien Couvreur Date: Sun, 8 May 2022 19:24:58 -0700 Subject: [PATCH 07/18] more details --- proposals/numeric-intptr.md | 63 ++++++++++++++++++------------------- 1 file changed, 30 insertions(+), 33 deletions(-) diff --git a/proposals/numeric-intptr.md b/proposals/numeric-intptr.md index ff6aae5683..24eb025abf 100644 --- a/proposals/numeric-intptr.md +++ b/proposals/numeric-intptr.md @@ -1,11 +1,5 @@ # Numeric IntPtr -TODO pointer arithmetic -TODO dynamic -TODO Possible breaking changes: IntPtr + int, IntPtr - int, (int)IntPtr, (IntPtr)long (and then of course various possible edge cases where user-defined vs language-defined operators subtly differ in behavior) -TODO Call out behavior with operators defined on IntPtr/UIntPtr -TODO Conversion to/from enumeration - ## Summary [summary]: #summary @@ -53,21 +47,20 @@ In other words, an __unmanaged_type__ is one of the following: ### 10.2.3 Implicit numeric conversions The implicit numeric conversions are: -TODO2 - -- From `sbyte` to `short`, `int`, `long`, `float`, `double`, or `decimal`. -- From `byte` to `short`, `ushort`, `int`, `uint`, `long`, `ulong`, `float`, `double`, or `decimal`. -- From `short` to `int`, `long`, `float`, `double`, or `decimal`. -- From `ushort` to `int`, `uint`, `long`, `ulong`, `float`, `double`, or `decimal`. -- From `int` to `long`, `float`, `double`, or `decimal`. -- From `uint` to `long`, `ulong`, `float`, `double`, or `decimal`. + +- From `sbyte` to `short`, `int`, **`nint`**, `long`, `float`, `double`, or `decimal`. +- From `byte` to `short`, `ushort`, `int`, `uint`, **`nint`, `nuint`**, `long`, `ulong`, `float`, `double`, or `decimal`. +- From `short` to `int`, **`nint`**, `long`, `float`, `double`, or `decimal`. +- From `ushort` to `int`, `uint`, **`nint`, `nuint`**, `long`, `ulong`, `float`, `double`, or `decimal`. +- From `int` to **`nint`**, `long`, `float`, `double`, or `decimal`. +- From `uint` to **`nuint`**, `long`, `ulong`, `float`, `double`, or `decimal`. +- **From `nint` to `long`, `float`, `double`, or `decimal`.** +- **From `nuint` to `ulong`, `float`, `double`, or `decimal`.** - From `long` to `float`, `double`, or `decimal`. - From `ulong` to `float`, `double`, or `decimal`. -- From `char` to `ushort`, `int`, `uint`, `long`, `ulong`, `float`, `double`, or `decimal`. +- From `char` to `ushort`, `int`, `uint`, **`nint`, `nuint`**, `long`, `ulong`, `float`, `double`, or `decimal`. - From `float` to `double`. -Conversions from `int`, `uint`, `long` or `ulong` to `float` and from `long` or `ulong` to `double` may cause a loss of precision, but will never cause a loss of magnitude. The other implicit numeric conversions never lose any information. - \[...] ### 10.2.11 Implicit constant expression conversions @@ -81,29 +74,29 @@ An implicit constant expression conversion permits the following conversions: The explicit numeric conversions are the conversions from a *numeric_type* to another *numeric_type* for which an implicit numeric conversion does not already exist: -TODO2 -- From `sbyte` to `byte`, `ushort`, `uint`, `ulong`, or `char`. +- From `sbyte` to `byte`, `ushort`, `uint`, **`nuint`**, `ulong`, or `char`. - From `byte` to `sbyte` or `char`. -- From `short` to `sbyte`, `byte`, `ushort`, `uint`, `ulong`, or `char`. +- From `short` to `sbyte`, `byte`, `ushort`, `uint`, **`nuint`**, `ulong`, or `char`. - From `ushort` to `sbyte`, `byte`, `short`, or `char`. -- From `int` to `sbyte`, `byte`, `short`, `ushort`, `uint`, `ulong`, or `char`. -- From `uint` to `sbyte`, `byte`, `short`, `ushort`, `int`, or `char`. -- From `long` to `sbyte`, `byte`, `short`, `ushort`, `int`, `uint`, `ulong`, or `char`. -- From `ulong` to `sbyte`, `byte`, `short`, `ushort`, `int`, `uint`, `long`, or `char`. +- From `int` to `sbyte`, `byte`, `short`, `ushort`, `uint`, **`nuint`**, `ulong`, or `char`. +- From `uint` to `sbyte`, `byte`, `short`, `ushort`, `int`, **`nint`**, or `char`. +- From `long` to `sbyte`, `byte`, `short`, `ushort`, `int`, `uint`, **`nint`, `nuint`**, `ulong`, or `char`. +- **From `nint` to `sbyte`, `byte`, `short`, `ushort`, `int`, `uint`, `nuint`, `ulong`, or `char`.** +- **From `nuint` to `sbyte`, `byte`, `short`, `ushort`, `int`, `uint`, `nint`, `long`, or `char`.** +- From `ulong` to `sbyte`, `byte`, `short`, `ushort`, `int`, `uint`, **`nint`, `nuint`**, `long`, or `char`. - From `char` to `sbyte`, `byte`, or `short`. -- From `float` to `sbyte`, `byte`, `short`, `ushort`, `int`, `uint`, `long`, `ulong`, `char`, or `decimal`. -- From `double` to `sbyte`, `byte`, `short`, `ushort`, `int`, `uint`, `long`, `ulong`, `char`, `float`, or `decimal`. -- From `decimal` to `sbyte`, `byte`, `short`, `ushort`, `int`, `uint`, `long`, `ulong`, `char`, `float`, or `double`. +- From `float` to `sbyte`, `byte`, `short`, `ushort`, `int`, `uint`, **`nint`, `nuint`**, `long`, `ulong`, `char`, or `decimal`. +- From `double` to `sbyte`, `byte`, `short`, `ushort`, `int`, `uint`, **`nint`, `nuint`**, `long`, `ulong`, `char`, `float`, or `decimal`. +- From `decimal` to `sbyte`, `byte`, `short`, `ushort`, `int`, `uint`, **`nint`, `nuint`**, `long`, `ulong`, `char`, `float`, or `double`. \[...] ### 10.3.3 Explicit enumeration conversions -TODO The explicit enumeration conversions are: -- From `sbyte`, `byte`, `short`, `ushort`, `int`, `uint`, `long`, `ulong`, `char`, `float`, `double`, or `decimal` to any *enum_type*. -- From any *enum_type* to `sbyte`, `byte`, `short`, `ushort`, `int`, `uint`, `long`, `ulong`, `char`, `float`, `double`, or `decimal`. +- From `sbyte`, `byte`, `short`, `ushort`, `int`, `uint`, **`nint`, `nuint`**, `long`, `ulong`, `char`, `float`, `double`, or `decimal` to any *enum_type*. +- From any *enum_type* to `sbyte`, `byte`, `short`, `ushort`, `int`, `uint`, **`nint`, `nuint`**, `long`, `ulong`, `char`, `float`, `double`, or `decimal`. - From any *enum_type* to any other *enum_type*. ### 11.8.2 Unary plus operator @@ -139,8 +132,6 @@ The predefined unary minus operators are: nint operator –(nint x); ``` - The result is computed by ... TODO2 - ### 11.7.14 Postfix increment and decrement operators Predefined `++` and `--` operators exist for the following types: `sbyte`, `byte`, `short`, `ushort`, `int`, `uint`, **`nint`, `nuint`**, `long`, `ulong`, `char`, `float`, `double`, `decimal`, and any enum type. @@ -306,4 +297,10 @@ A constant expression may be either a value type or a reference type. If a const \[...] -An implicit constant expression conversion permits a constant expression of type `int` to be converted to `sbyte`, `byte`, `short`, `ushort`, `nint`, `uint`, `nuint`, or `ulong`, provided the value of the constant expression is within the range of the destination type. +An implicit constant expression conversion permits a constant expression of type `int` to be converted to `sbyte`, `byte`, `short`, `ushort`, `uint`, **`nint`, `nuint`,** or `ulong`, provided the value of the constant expression is within the range of the destination type. + +TODO pointer arithmetic +TODO dynamic +TODO Possible breaking changes: IntPtr + int, IntPtr - int, (int)IntPtr, (IntPtr)long (and then of course various possible edge cases where user-defined vs language-defined operators subtly differ in behavior) +TODO Call out behavior with operators defined on IntPtr/UIntPtr + From 16dacb73050102891488dd02cc1e779c88c5d0ae Mon Sep 17 00:00:00 2001 From: Julien Couvreur Date: Sun, 8 May 2022 19:28:04 -0700 Subject: [PATCH 08/18] cleanup --- proposals/numeric-intptr.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/proposals/numeric-intptr.md b/proposals/numeric-intptr.md index 24eb025abf..dc48d509be 100644 --- a/proposals/numeric-intptr.md +++ b/proposals/numeric-intptr.md @@ -10,7 +10,8 @@ In short, we now treat `nint`/`nuint` as simple types aliasing `System.IntPtr`/` [design]: #design ### 8.3.5 Simple types -https://github.com/dotnet/csharpstandard/blob/draft-v7/standard/types.md#835-simple-types + +C# provides a set of predefined `struct` types called the simple types. The simple types are identified through keywords, but these keywords are simply aliases for predefined `struct` types in the `System` namespace, as described in the table below. **Keyword** | **Aliased type** ----------- | ------------------ @@ -30,11 +31,11 @@ https://github.com/dotnet/csharpstandard/blob/draft-v7/standard/types.md#835-sim `bool` | `System.Boolean` `decimal` | `System.Decimal` +\[...] + ### 8.3.6 Integral types -C# supports **eleven** integral types: `sbyte`, `byte`, `short`, `ushort`, `int`, `uint`, **`nint`, `nuint`**, `long`, `ulong`, and `char`. The integral types have the following sizes and ranges of values: -... -- **The int type represents signed 32-bit integers with values from -2147483648 to 2147483647, inclusive.** TODO2 for nint and nuint +C# supports **eleven** integral types: `sbyte`, `byte`, `short`, `ushort`, `int`, `uint`, **`nint`, `nuint`**, `long`, `ulong`, and `char`. \[...] ## 8.8 Unmanaged types From 2198d26be52df61f86a30515bb4e7d58bf698daa Mon Sep 17 00:00:00 2001 From: Julien Couvreur Date: Sun, 8 May 2022 22:15:26 -0700 Subject: [PATCH 09/18] typo --- proposals/numeric-intptr.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/proposals/numeric-intptr.md b/proposals/numeric-intptr.md index dc48d509be..122888e0ec 100644 --- a/proposals/numeric-intptr.md +++ b/proposals/numeric-intptr.md @@ -120,7 +120,7 @@ nuint operator +(nuint x); ### 11.7.14 Postfix increment and decrement operators -Unary operator overload resolution is applied to select a specific operator implementation. Predefined `++` and `--` operators exist for the following types: `sbyte`, `byte`, `short`, `ushort`, `int`, `uint`, **`nint*, `nuint`**, `long`, `ulong`, `char`, `float`, `double`, `decimal`, and any enum type. +Unary operator overload resolution is applied to select a specific operator implementation. Predefined `++` and `--` operators exist for the following types: `sbyte`, `byte`, `short`, `ushort`, `int`, `uint`, **`nint, `nuint`**, `long`, `ulong`, `char`, `float`, `double`, `decimal`, and any enum type. ### 11.8.3 Unary minus operator From 1b9f782d64840976a659d174261842b779522558 Mon Sep 17 00:00:00 2001 From: Julien Couvreur Date: Sun, 8 May 2022 22:16:07 -0700 Subject: [PATCH 10/18] cleanup --- proposals/numeric-intptr.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/proposals/numeric-intptr.md b/proposals/numeric-intptr.md index 122888e0ec..46d542ba0a 100644 --- a/proposals/numeric-intptr.md +++ b/proposals/numeric-intptr.md @@ -120,7 +120,7 @@ nuint operator +(nuint x); ### 11.7.14 Postfix increment and decrement operators -Unary operator overload resolution is applied to select a specific operator implementation. Predefined `++` and `--` operators exist for the following types: `sbyte`, `byte`, `short`, `ushort`, `int`, `uint`, **`nint, `nuint`**, `long`, `ulong`, `char`, `float`, `double`, `decimal`, and any enum type. +Unary operator overload resolution is applied to select a specific operator implementation. Predefined `++` and `--` operators exist for the following types: `sbyte`, `byte`, `short`, `ushort`, `int`, `uint`, **`nint, `nuint`,** `long`, `ulong`, `char`, `float`, `double`, `decimal`, and any enum type. ### 11.8.3 Unary minus operator From 08a1d3713ddf57873f880a63c6d13bb81b254e92 Mon Sep 17 00:00:00 2001 From: Julien Couvreur Date: Sun, 8 May 2022 22:16:47 -0700 Subject: [PATCH 11/18] typo --- proposals/numeric-intptr.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/proposals/numeric-intptr.md b/proposals/numeric-intptr.md index 46d542ba0a..02e870af19 100644 --- a/proposals/numeric-intptr.md +++ b/proposals/numeric-intptr.md @@ -120,7 +120,7 @@ nuint operator +(nuint x); ### 11.7.14 Postfix increment and decrement operators -Unary operator overload resolution is applied to select a specific operator implementation. Predefined `++` and `--` operators exist for the following types: `sbyte`, `byte`, `short`, `ushort`, `int`, `uint`, **`nint, `nuint`,** `long`, `ulong`, `char`, `float`, `double`, `decimal`, and any enum type. +Unary operator overload resolution is applied to select a specific operator implementation. Predefined `++` and `--` operators exist for the following types: `sbyte`, `byte`, `short`, `ushort`, `int`, `uint`, **`nint`, `nuint`,** `long`, `ulong`, `char`, `float`, `double`, `decimal`, and any enum type. ### 11.8.3 Unary minus operator From d9120989f451545142988af375dfa752c91ba8c6 Mon Sep 17 00:00:00 2001 From: Julien Couvreur Date: Wed, 11 May 2022 09:24:46 -0700 Subject: [PATCH 12/18] include better conversion target section --- proposals/numeric-intptr.md | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/proposals/numeric-intptr.md b/proposals/numeric-intptr.md index 02e870af19..29a257ecf1 100644 --- a/proposals/numeric-intptr.md +++ b/proposals/numeric-intptr.md @@ -100,17 +100,15 @@ The explicit enumeration conversions are: - From any *enum_type* to `sbyte`, `byte`, `short`, `ushort`, `int`, `uint`, **`nint`, `nuint`**, `long`, `ulong`, `char`, `float`, `double`, or `decimal`. - From any *enum_type* to any other *enum_type*. -### 11.8.2 Unary plus operator +# 11 Expressions -The predefined unary plus operators are: +#### 11.6.4.6 Better conversion target -```csharp -... -nint operator +(nint x); -nuint operator +(nuint x); -``` +Given two types `T₁` and `T₂`, `T₁` is a ***better conversion target*** than `T₂` if one of the following holds: -# 11 Expressions +- An implicit conversion from `T₁` to `T₂` exists and no implicit conversion from `T₂` to `T₁` exists +- `T₁` is `Task`, `T₂` is `Task`, and `S₁` is a better conversion target than `S₂` +- `T₁` is `S₁` or `S₁?` where `S₁` is a signed integral type, and `T₂` is `S₂` or `S₂?` where `S₂` is an unsigned integral type. Specifically: \[...] ### 11.7.10 Element access @@ -122,6 +120,16 @@ nuint operator +(nuint x); Unary operator overload resolution is applied to select a specific operator implementation. Predefined `++` and `--` operators exist for the following types: `sbyte`, `byte`, `short`, `ushort`, `int`, `uint`, **`nint`, `nuint`,** `long`, `ulong`, `char`, `float`, `double`, `decimal`, and any enum type. +### 11.8.2 Unary plus operator + +The predefined unary plus operators are: + +```csharp +... +nint operator +(nint x); +nuint operator +(nuint x); +``` + ### 11.8.3 Unary minus operator The predefined unary minus operators are: From 5d97bdb1e60ae84a8dc8754fea2019279cf51faf Mon Sep 17 00:00:00 2001 From: Julien Couvreur Date: Sun, 15 May 2022 23:40:35 -0700 Subject: [PATCH 13/18] Add mask for shift operations --- proposals/numeric-intptr.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/proposals/numeric-intptr.md b/proposals/numeric-intptr.md index 29a257ecf1..31a1088369 100644 --- a/proposals/numeric-intptr.md +++ b/proposals/numeric-intptr.md @@ -255,6 +255,11 @@ The predefined shift operators are listed below. nuint operator >>>(nuint x, nint count); ``` +For the predefined operators, the number of bits to shift is computed as follows: +\[...] +- When the type of `x` is `nint` or `nuint`, the shift count is given by the low-order five bits of `count` on a 32 bits platform, or the lower-order six bits of `count` on a 64 bits platform. +The shift count is computed from `count & (sizeof(nint) * 8 - 1)`, which is `count & 0x1F` on a 32 bits platform and `count & 0x3F` on a 64 bits platform. + ## 11.11 Relational and type-testing operators ### 11.11.2 Integer comparison operators From fbe92523a0fdcf1c1520ad37cc75618f7b880176 Mon Sep 17 00:00:00 2001 From: Julien Couvreur Date: Tue, 24 May 2022 11:58:28 -0700 Subject: [PATCH 14/18] Remaining TODOs --- proposals/numeric-intptr.md | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/proposals/numeric-intptr.md b/proposals/numeric-intptr.md index 31a1088369..ea35512d88 100644 --- a/proposals/numeric-intptr.md +++ b/proposals/numeric-intptr.md @@ -313,8 +313,32 @@ A constant expression may be either a value type or a reference type. If a const An implicit constant expression conversion permits a constant expression of type `int` to be converted to `sbyte`, `byte`, `short`, `ushort`, `uint`, **`nint`, `nuint`,** or `ulong`, provided the value of the constant expression is within the range of the destination type. -TODO pointer arithmetic -TODO dynamic -TODO Possible breaking changes: IntPtr + int, IntPtr - int, (int)IntPtr, (IntPtr)long (and then of course various possible edge cases where user-defined vs language-defined operators subtly differ in behavior) -TODO Call out behavior with operators defined on IntPtr/UIntPtr +## 22.5 Pointer conversions + +### 22.5.1 General + +\[...] + +Additionally, in an unsafe context, the set of available explicit conversions is extended to include the following explicit pointer conversions: + +- From any *pointer_type* to any other *pointer_type*. +- From `sbyte`, `byte`, `short`, `ushort`, `int`, `uint`, **`nint`, `nuint`,** `long`, or `ulong` to any *pointer_type*. +- From any *pointer_type* to `sbyte`, `byte`, `short`, `ushort`, `int`, `uint`, **`nint`, `nuint`,** `long`, or `ulong`. + +## Various considerations + +### Breaking changes + +One of the main impacts of this design is that `System.IntPtr` and `System.IntPtr` gain some built-in operators (conversions, unary and binary). +Those include `checked` operators, which means that some operators on those types will now throw when overflowing. For example: +- `IntPtr + int` +- `IntPtr - int` +- `IntPtr -> int` +- `long -> IntPtr` +- `void* -> IntPtr` + +### Metadata encoding + +This design means that `nint` and `nuint` can simply be emitted as `System.IntPtr` and `System.UIntPtr`, without the use of `System.Runtime.CompilerServices.NativeIntegerAttribute`. +Similarly, when loading metadata `NativeIntegerAttribute` can be ignored. From ef09fbf9acf4f492d9f78c3f34c537182fbde57c Mon Sep 17 00:00:00 2001 From: Julien Couvreur Date: Tue, 24 May 2022 16:05:10 -0700 Subject: [PATCH 15/18] typo --- proposals/numeric-intptr.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/proposals/numeric-intptr.md b/proposals/numeric-intptr.md index ea35512d88..86de76d8d8 100644 --- a/proposals/numeric-intptr.md +++ b/proposals/numeric-intptr.md @@ -329,7 +329,7 @@ Additionally, in an unsafe context, the set of available explicit conversions is ### Breaking changes -One of the main impacts of this design is that `System.IntPtr` and `System.IntPtr` gain some built-in operators (conversions, unary and binary). +One of the main impacts of this design is that `System.IntPtr` and `System.UIntPtr` gain some built-in operators (conversions, unary and binary). Those include `checked` operators, which means that some operators on those types will now throw when overflowing. For example: - `IntPtr + int` - `IntPtr - int` From 170cf0abad578b87518320bdcffd07e80f668dc1 Mon Sep 17 00:00:00 2001 From: Julien Couvreur Date: Wed, 25 May 2022 11:28:57 -0700 Subject: [PATCH 16/18] Address feedback from Chuck --- proposals/numeric-intptr.md | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/proposals/numeric-intptr.md b/proposals/numeric-intptr.md index 86de76d8d8..fb344bdc44 100644 --- a/proposals/numeric-intptr.md +++ b/proposals/numeric-intptr.md @@ -39,7 +39,7 @@ C# supports **eleven** integral types: `sbyte`, `byte`, `short`, `ushort`, `int` ## 8.8 Unmanaged types -In other words, an __unmanaged_type__ is one of the following: +In other words, an **unmanaged_type** is one of the following: - `sbyte`, `byte`, `short`, `ushort`, `int`, `uint`, **`nint`, `nuint`**, `long`, `ulong`, `char`, `float`, `double`, `decimal`, or `bool`. - Any *enum_type*. - Any user-defined *struct_type* that is not a constructed type and contains fields of *unmanaged_type*s only. @@ -116,6 +116,12 @@ Given two types `T₁` and `T₂`, `T₁` is a ***better conversion target*** th #### 11.7.10.2 Array access +\[...] The number of expressions in the *argument_list* shall be the same as the rank of the *array_type*, and each expression shall be of type `int`, `uint`, **`nint`, `nuint`**, `long`, or `ulong,` or shall be implicitly convertible to one or more of these types. + +\[...] The run-time processing of an array access of the form `P[A]`, where `P` is a *primary_no_array_creation_expression* of an *array_type* and `A` is an *argument_list*, consists of the following steps: +\[...] +- The index expressions of the *argument_list* are evaluated in order, from left to right. Following evaluation of each index expression, an implicit conversion to one of the following types is performed: `int`, `uint`, **`nint`, `nuint`**, `long`, `ulong`. The first type in this list for which an implicit conversion exists is chosen. \[...] + ### 11.7.14 Postfix increment and decrement operators Unary operator overload resolution is applied to select a specific operator implementation. Predefined `++` and `--` operators exist for the following types: `sbyte`, `byte`, `short`, `ushort`, `int`, `uint`, **`nint`, `nuint`,** `long`, `ulong`, `char`, `float`, `double`, `decimal`, and any enum type. @@ -257,8 +263,8 @@ The predefined shift operators are listed below. For the predefined operators, the number of bits to shift is computed as follows: \[...] -- When the type of `x` is `nint` or `nuint`, the shift count is given by the low-order five bits of `count` on a 32 bits platform, or the lower-order six bits of `count` on a 64 bits platform. -The shift count is computed from `count & (sizeof(nint) * 8 - 1)`, which is `count & 0x1F` on a 32 bits platform and `count & 0x3F` on a 64 bits platform. +- When the type of `x` is `nint` or `nuint`, the shift count is given by the low-order five bits of `count` on a 32 bit platform, or the lower-order six bits of `count` on a 64 bit platform. + ## 11.11 Relational and type-testing operators From c3343b3e566da4ea941a21ec7c5ec42d7534f225 Mon Sep 17 00:00:00 2001 From: Julien Couvreur Date: Wed, 25 May 2022 11:38:15 -0700 Subject: [PATCH 17/18] unchecked breaks --- proposals/numeric-intptr.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/proposals/numeric-intptr.md b/proposals/numeric-intptr.md index fb344bdc44..4a00581b1f 100644 --- a/proposals/numeric-intptr.md +++ b/proposals/numeric-intptr.md @@ -336,7 +336,7 @@ Additionally, in an unsafe context, the set of available explicit conversions is ### Breaking changes One of the main impacts of this design is that `System.IntPtr` and `System.UIntPtr` gain some built-in operators (conversions, unary and binary). -Those include `checked` operators, which means that some operators on those types will now throw when overflowing. For example: +Those include `checked` operators, which means that the following operators on those types will now throw when overflowing: - `IntPtr + int` - `IntPtr - int` - `IntPtr -> int` From 2d47d8c404ed8aa0a90b00900c2769642e610a0d Mon Sep 17 00:00:00 2001 From: Julien Couvreur Date: Wed, 25 May 2022 11:59:58 -0700 Subject: [PATCH 18/18] Italic --- proposals/numeric-intptr.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/proposals/numeric-intptr.md b/proposals/numeric-intptr.md index 4a00581b1f..163f6ff021 100644 --- a/proposals/numeric-intptr.md +++ b/proposals/numeric-intptr.md @@ -39,7 +39,7 @@ C# supports **eleven** integral types: `sbyte`, `byte`, `short`, `ushort`, `int` ## 8.8 Unmanaged types -In other words, an **unmanaged_type** is one of the following: +In other words, an *unmanaged_type* is one of the following: - `sbyte`, `byte`, `short`, `ushort`, `int`, `uint`, **`nint`, `nuint`**, `long`, `ulong`, `char`, `float`, `double`, `decimal`, or `bool`. - Any *enum_type*. - Any user-defined *struct_type* that is not a constructed type and contains fields of *unmanaged_type*s only.