[m-rev.] for review: proposed changes to term module

Julien Fischer jfischer at opturion.com
Tue Apr 18 09:04:37 AEST 2017

Hi all,

The diff below is a proposed change to the representation of integers in the
library's term module.  It merges the current integer/1 and big_integer/2
constructors and extends the representation so we can distinguish between
different signedness and sizes of integers.  The immediate use of this will be
to support uint literals; later will will also use it to support literals for
the upcoming fixed size integer types.  I have successfully bootchecked the
compiler.  I will post the full diff after I have feedback on the proposed
change to the term data structure below.  (Note that there is a copy of the term
module from before this change in the extras.)

A couple of other things in relation to this:

1. Zoltan, I believe you have some non-committed changes to
compiler/fact_table.m.  There will almost certainly be conflicts with the full
version of this change, so could you please let me know what you want to do

2. The compiler currently accepts non-decimal integer literals in some
odd places, for example when specifying a symname and arity, for example

     :- pragma obsolete(foo/0x4).

My current version of this change will cause it to reject non-decimal
integers in such places; does anyone want to preserve this behaviour?

diff --git a/library/term.m b/library/term.m
index feab9cf..b3036a4 100644
--- a/library/term.m
+++ b/library/term.m
@@ -55,9 +55,12 @@

  :- type const
      --->    atom(string)
-    ;       integer(int)
-    ;       big_integer(integer_base, integer)
-            % An integer that is too big for `int'.
+    ;       integer(
+                integer_base       :: integer_base,
+                integer_value      :: integer,
+                integer_signedness :: signedness,
+                integer_size       :: integer_size
+            )
      ;       string(string)
      ;       float(float)
      ;       implementation_defined(string).
@@ -68,6 +71,17 @@
      ;       base_10
      ;       base_16.

+:- type signedness
+    --->    signed
+    ;       unsigned.
+:- type integer_size
+    --->    size_word.
+    %;       size_8bit
+    %;       size_16bit
+    %;       size_32bit
+    %;       size_64bit
  :- type generic
      --->    generic.


More information about the reviews mailing list