[mercury-users] Circular lists

Fergus Henderson fjh at cs.mu.oz.au
Thu Nov 27 15:50:46 AEDT 1997


On Thu, Nov 27, 1997 at 03:30:27PM +1100, Richard A. O'Keefe wrote:
> 	I guess we could emit a warning every time you return a string from C
> 	code, or pass or return a complex type from C code,
> 
> Why are these things dangerous? In Quintus Prolog, passing strings in either
> direction was guaranteed safe, thanks to copying.

Well, that's a fairly high price to pay.

If I have to choose between efficiency and safety,
for a feature like the foreign language interface,
I'd rather have efficiency.

> In ESH, a very nice Scheme
> system from Sun, passing C data structures to Scheme and back again works
> perfectly safely.

What exactly do you mean by safely here?  Does ESH do a deep copy of the
C data structures?  If not, what happens if the C code deallocates the
memory used for the data structures while they are still being used
by Scheme?

Passing C data structures to Mercury and back again is fairly safe,
if you pass them as opaque data structures.  I don't think I'd call
it "perfectly safe", but I don't think perfect safety is a realistically
achievable goal in this context.

-- 
Fergus Henderson <fjh at cs.mu.oz.au>   WWW: <http://www.cs.mu.oz.au/~fjh>  
Note: due to some buggy software and a (probably accidental)
denial-of-service attack, any mail sent to me between
	Tue Nov 25 20:00:00 UTC (6am Wed, local time)
and	Wed Nov 26 06:00:00 UTC (4pm, local time)
may have gone into the bit-bucket.  Please re-send it.



More information about the users mailing list