[m-dev.] For review: Add implementation of reference types (global heap)

Peter Schachte pets at students.cs.mu.OZ.AU
Wed Jun 10 10:40:26 AEST 1998


On Wed, 10 Jun 1998, Fergus Henderson wrote:

> > %  This type is not really used.  I'd rather define this as c_pointer, but
> > %  there's a bug in the Mercury compiler that makes that not work.
> > :- type nb_reference(T) ---> nb_reference(c_pointer).
> 
> The first sentence in that comment is a bit misleading.
> I suggest you replace it with "This type is implemented in C."
> 
> Regarding the second sentence,
> It's true that there is a bug in the Mercury compiler that makes
> 
> 	:- type nb_reference(T) == c_pointer.
> 
> not work.  However, the definition using == is actually less useful
> than the one above, IMHO, since the one above gives you more informative
> output from type_of/1, io__write/3, etc.
> Thus I suggest you delete the second sentence.

Now that I think about it,

	:- type nb_reference(T) == c_pointer.

isn't really what I want to write.  In fact

	:- type nb_reference(T) ---> nb_reference(c_pointer).

isn't quite right, either, because I don't want even this module to be
trying to poke around inside it.  The type should be abstract even in this
module. What I'd really rather write is just

	:- type nb_reference(T).

(which already appears in the interface section).  The type is defined
entirely in C, and as far as Mercury is concerned, it's a Word and that's
all it needs to know. 

So why not allow a type to be defined abstractly, with no concrete type
declaration at all, and only complain if some attempt is made to "look
inside" an instance of that type?  This seems more in keeping with the
overall style of Mercury. 


-Peter Schachte               | We hang the petty thieves and appoint the
mailto:pets at cs.mu.OZ.AU       | great ones to public office.
http://www.cs.mu.oz.au/~pets/ |     -- Aesop 
PGP: finger pets at 128.250.37.3 | 




More information about the developers mailing list