[m-rev.] for review: fix confusion between MR_bool and MR_Bool

Julien Fischer juliensf at csse.unimelb.edu.au
Mon Jul 12 18:01:49 AEST 2010


Branches: 10.04, main

Sort out the confusion in various places between MR_bool and MR_Bool.
MR_Bool is intended to be the C representation of the library type
bool.bool/0; MR_bool a Boolean type for use in the Mercury implementation.

In 2002, MR_Bool was deprecated, the intention apparently being to replace it
with MR_bool.  This doesn't actually work since the two are not always
interchangeable: MR_bool is a typedef for an int, while MR_Bool is word-sized -
on x86-64 for example,  the former is a 32-bits, the latter has 64-bits.  (The
mismatch can be source of confusion in foreign_procs that manipulate values of
type bool.bool/0.)

Another minor point is that if we are going to have the runtime define a
typedef for the C representation of bool.bool/0 then it should at least be
consistent with the names used for other types, e.g.

 	char              -  MR_Char
 	int               -  MR_Integer
 	float		  -  MR_Float
 	comparison_result -  MR_Comparison_Result
 	bool              -  MR_Bool (rather than MR_bool)

 	etc ...

This change reinstates MR_Bool (making into a typedef for MR_Word in
the process) and updates the ``C data passing conventions'' section of
the reference manual accordingly.

runtime/mercury_bootstrap.h:
 	Delete the definition of MR_Bool from here.
 	(This change addresses the XXX here.)

runtime/mercury_types.h:
 	Put the definition of MR_Bool back here.

doc/reference_manual.texi:
 	The C type corresponding to bool.bool/0 is MR_Bool not MR_bool.

library/pretty_printer.m:
 	Use MR_NO rather than MR_FALSE in a spot.  (The two are identical
 	but the former is preferable in the case where we are manipulating
 	a value of type bool.bool/0.)

 	Unrelated chage: avoid a warning concerning a pointer value being used
 	as an integer.
Julien.

Index: doc/reference_manual.texi
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/doc/reference_manual.texi,v
retrieving revision 1.444
diff -u -r1.444 reference_manual.texi
--- doc/reference_manual.texi	6 Jul 2010 12:33:10 -0000	1.444
+++ doc/reference_manual.texi	12 Jul 2010 07:09:38 -0000
@@ -6871,7 +6871,7 @@
  given by the corresponding typedef.

  For the Mercury standard library type @samp{bool.bool}, there is a 
-corresponding C type, @code{MR_bool}.  C code can refer to the boolean 
+corresponding C type, @code{MR_Bool}.  C code can refer to the boolean
  data constructors @samp{yes} and @samp{no}, as @code{MR_YES} and
  @code{MR_NO} respectively.

Index: library/pretty_printer.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/library/pretty_printer.m,v
retrieving revision 1.13
diff -u -r1.13 pretty_printer.m
--- library/pretty_printer.m	17 May 2010 07:17:12 -0000	1.13
+++ library/pretty_printer.m	12 Jul 2010 06:59:52 -0000
@@ -908,8 +908,8 @@
  ").
  :- pragma foreign_code("C",
  "
-    MR_Bool ML_pretty_printer_is_initialised = MR_FALSE;
-    MR_Word ML_pretty_printer_default_formatter_map = NULL;
+    MR_Bool ML_pretty_printer_is_initialised = MR_NO;
+    MR_Word ML_pretty_printer_default_formatter_map = 0;
  ").

  :- pragma foreign_code("Java",
Index: runtime/mercury_bootstrap.h
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/runtime/mercury_bootstrap.h,v
retrieving revision 1.42
diff -u -r1.42 mercury_bootstrap.h
--- runtime/mercury_bootstrap.h	21 Oct 2009 04:30:18 -0000	1.42
+++ runtime/mercury_bootstrap.h	12 Jul 2010 07:07:26 -0000
@@ -17,26 +17,6 @@

  /*---------------------------------------------------------------------------*/
  /*
-** This stuff is enabled by default,
-** but you can disable it by defining MR_NO_BACKWARDS_COMPAT.
-*/
-
-#ifndef MR_NO_BACKWARDS_COMPAT
-
-/*
-** MR_Bool is the C representation for the Mercury type bool__bool.
-** For ordinary booleans, use MR_bool in mercury_std.h.
-**
-** XXX Why is it not defined defined to be MR_Word, and why is the definition
-** here?
-*/
-
-typedef MR_intptr_t		MR_Bool;
-
-#endif	/* !MR_NO_BACKWARDS_COMPAT */
-
-/*---------------------------------------------------------------------------*/
-/*
  ** This stuff is not enabled by default.
  ** To enable it, you must explicitly define MR_EXTRA_BACKWARDS_COMPAT.
  */
Index: runtime/mercury_types.h
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/runtime/mercury_types.h,v
retrieving revision 1.58
diff -u -r1.58 mercury_types.h
--- runtime/mercury_types.h	30 Oct 2009 03:33:30 -0000	1.58
+++ runtime/mercury_types.h	12 Jul 2010 07:07:06 -0000
@@ -88,6 +88,12 @@
  typedef MR_uintptr_t            MR_Unsigned;

  /*
+** MR_Bool is the C representation for the Mercury type bool.bool/0.
+** For ordinary booleans, use MR_bool in mercury_std.h.
+*/
+typedef MR_Word                 MR_Bool;
+
+/*
  ** Convert a size in bytes to a size in words, rounding up if necessary.
  */



--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to:       mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions:          mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------



More information about the reviews mailing list