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

Fergus Henderson fjh at cs.mu.OZ.AU
Wed Jun 10 16:00:53 AEST 1998


On 10-Jun-1998, Peter Schachte <pets at students.cs.mu.oz.au> wrote:
> 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 declaration you're talking about doesn't let this module
poke around inside it.  So I don't see what you're complaining about.

> 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. 

Well, if we were going to allow something like this, I think we should
require some kind of explicit declaration, rather than just
assuming that if it is not defined here then it is defined elsewhere.
Declaring a type and not defining it ought to be an error
(just as declaring a predicate or function and not definition it is
an error).

The declaration to say that a type is defined in a different language
could be something similar to `pragma import', but for types, i.e.
	:- pragma import_type(nb_reference).
or
	:- pragma import_type(nb_reference, "C").

But you can already accomplish basically the same thing, using the
`c_pointer' abstract data type, so I don't think this sort of
extension would be worthwhile.

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh>  |  of excellence is a lethal habit"
PGP: finger fjh at 128.250.37.3        |     -- the last words of T. S. Garp.



More information about the developers mailing list