[m-rev.] for review: more namespace cleanliness changes

Simon Taylor stayl at cs.mu.OZ.AU
Mon Feb 18 17:55:18 AEDT 2002


On 18-Feb-2002, Fergus Henderson <fjh at cs.mu.OZ.AU> wrote:
> On 16-Feb-2002, Simon Taylor <stayl at cs.mu.OZ.AU> wrote:
> > 
> > compiler/export.m:
> > compiler/ml_code_gen.m:
> > 	Use MR_bool rather than MR_Bool (I think MR_Bool is
> > 	meant to be for references to the Mercury type
> > 	bool__bool).
> 
> Your parenthetical remark here is correct.
> 
> It might be better to rename MR_Bool as MR_Mercury_Bool (as was done
> with MR_Mercury_Type_Info), to avoid confusion between the two.

Separate change.
 
> Also it would be good to add a comment at the definition of MR_Bool
> explaining this.

I had already done that, it just wasn't in the part of the diff I posted.

> > +++ runtime/mercury_std.h	15 Feb 2002 05:49:39 -0000
> ...
> > +#define	MR_bool		char
> 
> It would be nicer to use a typedef rather than a #define.
> (Previously the #define was needed to avoid conflicts,
> but now that you've renamed it, there's no reason to not
> use a typedef.)

Done.

> > +/*
> > +** XXX mercury_goto.h checks the value of MR_PIC, not whether
> > +** it is defined, so this won't work if -DPIC=0 is passed
> > +** on the command line. mmake/mercury_compile don't do that.
> > +*/
> > +#ifdef PIC
> > +  #define MR_PIC 1
> > +  #undef PIC
> > +#endif
> 
> The XXX comment here raises the question: why not just use `#if PIC'
> rather than `#ifdef PIC' here?  If PIC is not defined, then `#if PIC'
> will expand to `#if 0'.

Fixed.

Simon.


Estimated hours taken: 4
Branches: main

Add MR_ prefixes to the remaining non-prefixed symbols.

This change will require all workspaces to be updated
The compiler will start generating references to MR_TRUE, 
MR_bool, etc., which are not defined in the old runtime
header files.

runtime/mercury_std.h:
	Add MR_ prefixes to bool, TRUE, FALSE, max, min,
	streq, strdiff, strtest, strntest, strneq, strndiff,
	strntest, NO_RETURN.

	Delete a commented out definition of `reg'.

runtime/mercury_tags.h:
	Add an MR_ prefix to TAGBITS.

configure.in:
runtime/mercury_goto.h:
runtime/machdeps/i386_regs.h/mercury_goto.h:
	Add an MR_ prefix to PIC.

runtime/mercury_conf_param.h:
	Allow non-prefixed PIC and HIGHTAGS to be defined on
	the command line. 

runtime/mercury_bootstrap.h:
	Add backwards compatibility definitions.

RESERVED_MACRO_NAMES:
	Remove the renamed macros.

compiler/export.m:
compiler/ml_code_gen.m:
	Use MR_bool rather than MR_Bool (MR_Bool is
	meant to be for references to the Mercury type
	bool__bool).

runtime/mercury_types.h:
	Add a comment the MR_Bool is for references to
	bool__bool.

*/*.c:
*/*.h:
*/*.m:
	Add MR_ prefixes.

Index: mercury_types.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_types.h,v
retrieving revision 1.26
diff -u -u -r1.26 mercury_types.h
--- mercury_types.h	21 Feb 2001 05:53:43 -0000	1.26
+++ mercury_types.h	15 Feb 2002 05:49:39 -0000
@@ -57,6 +57,10 @@
 typedef	MR_uintptr_t		MR_Word;
 typedef	MR_intptr_t		MR_Integer;
 typedef	MR_uintptr_t		MR_Unsigned;
+/*
+** MR_Bool is the C representation for the Mercury type bool__bool.
+** For ordinary booleans, use MR_bool in mercury_std.h.
+*/
 typedef	MR_intptr_t		MR_Bool;
 
 /*
--- mercury_std.h	2002/02/18 03:51:55	1.1
+++ mercury_std.h	2002/02/18 04:00:00
@@ -27,7 +27,7 @@
   #include "safe-ctype.h"
 #endif
 
-#define	MR_bool		char
+typedef	char		MR_bool;
 
 #define	MR_max(a, b)	((a) > (b) ? (a) : (b))
 #define	MR_min(a, b)	((a) < (b) ? (a) : (b))
--- mercury_conf_param.h	2002/02/18 03:51:55	1.1
+++ mercury_conf_param.h	2002/02/18 03:57:33
@@ -163,13 +163,12 @@
   #define MR_PIC_REG 1
   #undef PIC_REG
 #endif
-/*
-** XXX mercury_goto.h checks the value of MR_PIC, not whether
-** it is defined, so this won't work if -DPIC=0 is passed
-** on the command line. mmake/mercury_compile don't do that.
-*/
 #ifdef PIC
-  #define MR_PIC 1
+  #if PIC == 0
+    #define MR_PIC 0
+  #else
+    #define MR_PIC 1
+  #endif
   #undef PIC
 #endif
 #ifdef HIGHTAGS
--------------------------------------------------------------------------
mercury-reviews mailing list
post:  mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the reviews mailing list