[m-rev.] for review: define <<u and >>u

Zoltan Somogyi zoltan.somogyi at runbox.com
Wed Dec 7 11:56:49 AEDT 2022



On Tue, 06 Dec 2022 01:11:07 +1100 (AEDT), "Zoltan Somogyi" <zoltan.somogyi at runbox.com> wrote:
> Since this diff requires the installed compiler to recognize <<u and >>u
> as operators, I won't commit this until an rotd contains the both
> the change that enables that, and the new synonym for
> compiler-sufficiently-recent that I just added to options.m in order to allow
> configure to test for that. This won't be before wednesday.

The last rotd contains the change to the lexer that this diff
requires to be present in the installed compiler, so I would like to
commit this diff once the proposed change to NEWS below
has been reviewed. Does anyone want me to wait? Note that
the entry for uint.m fixes a typo in my previous diff to NEWS.

Zoltan.

diff --git a/NEWS b/NEWS
index 54bc67f3b..cecdd381f 100644
--- a/NEWS
+++ b/NEWS
@@ -39,6 +39,14 @@ Changes that may break compatibility
 * The digraph_key type in the digraph.m module is now an instance of
   the uenum typeclass, not the enum typeclass.
 
+* The character sequences `<<u` and `>>u` are now recognized as single tokens.
+  (They are the names of new versions of the left and right shift operators
+  that expect the shift amount to be specified by an unsigned integer;
+  previously, shift amounts were always specified by signed integers.)
+  This means that existing code in which a `<<` or `>>` operator was followed
+  immediately, without an intervening space, by a `u` character, will now
+  be parsed differently.
+
 * The compiler no longer accepts : as the module name separator in backquoted
   operators. (Mercury switched to using . as the module name separator
   around 2003.)
@@ -171,6 +179,51 @@ Changes to the Mercury standard library
 
     - The type `int` is now an instance of the new uenum typeclass.
 
+* The following predicates and functions have been added:
+
+    - func `<<u/2`
+    - func `>>u/2`
+    - func `unchecked_left_ushift/2`
+    - func `unchecked_right_ushift/2`
+    - func `ubits_per_int/0`
+    - pred `ubits_per_int/1`
+
+### Changes to the `int8` module
+
+* The following functions have been added:
+
+    - func `<<u/2`
+    - func `>>u/2`
+    - func `unchecked_left_ushift/2`
+    - func `unchecked_right_ushift/2`
+
+### Changes to the `int16` module
+
+* The following functions have been added:
+
+    - func `<<u/2`
+    - func `>>u/2`
+    - func `unchecked_left_ushift/2`
+    - func `unchecked_right_ushift/2`
+
+### Changes to the `int32` module
+
+* The following functions have been added:
+
+    - func `<<u/2`
+    - func `>>u/2`
+    - func `unchecked_left_ushift/2`
+    - func `unchecked_right_ushift/2`
+
+### Changes to the `int64` module
+
+* The following functions have been added:
+
+    - func `<<u/2`
+    - func `>>u/2`
+    - func `unchecked_left_ushift/2`
+    - func `unchecked_right_ushift/2`
+
 ### Changes to the `io` module
 
 * The following predicates have been added:
@@ -753,9 +806,49 @@ Changes to the Mercury standard library
 
     - The type `uint` is now an instance of the new uenum typeclass.
 
-* The following function has been added:
+* The following functions have been added:
 
-    - func `ubits_per_int/0`
+    - func `<<u/2`
+    - func `>>u/2`
+    - func `unchecked_left_ushift/2`
+    - func `unchecked_right_ushift/2`
+    - func `ubits_per_uint/0`
+
+### Changes to the `uint8` module
+
+* The following functions have been added:
+
+    - func `<<u/2`
+    - func `>>u/2`
+    - func `unchecked_left_ushift/2`
+    - func `unchecked_right_ushift/2`
+
+### Changes to the `uint16` module
+
+* The following functions have been added:
+
+    - func `<<u/2`
+    - func `>>u/2`
+    - func `unchecked_left_ushift/2`
+    - func `unchecked_right_ushift/2`
+
+### Changes to the `uint32` module
+
+* The following functions have been added:
+
+    - func `<<u/2`
+    - func `>>u/2`
+    - func `unchecked_left_ushift/2`
+    - func `unchecked_right_ushift/2`
+
+### Changes to the `uint64` module
+
+* The following functions have been added:
+
+    - func `<<u/2`
+    - func `>>u/2`
+    - func `unchecked_left_ushift/2`
+    - func `unchecked_right_ushift/2`
 
 ### Changes to the `version_array` module
 



More information about the reviews mailing list