[m-rev.] more .NET fixes/work-arounds (not committed)

Fergus Henderson fjh at cs.mu.OZ.AU
Fri Feb 14 17:17:45 AEDT 2003


On 14-Feb-2003, Zoltan Somogyi <zs at cs.mu.OZ.AU> wrote:
> On 13-Feb-2003, Fergus Henderson <fjh at cs.mu.OZ.AU> wrote:
> > compiler/stack_layout.m:
> > 	Implement concat_strings in Mercury.
> > 	(XXX FIXME Why was this ever implemented in C anyway?
> 
> Because the result of that operation is not really a Mercury string. It has
> embedded null characters, and you can't figure out how long the byte array
> is from its contents if you don't already know.

I see.  It would have been nice to have some comments in the source
about this.  In fact, it would be even better if all uses of `string'
which relied on this used a type named say `string_with_0s', even if
this type was just defined as an equivalence type for `string'.

> > +% This version is only used if there is no matching foreign_proc version.
> > +% XXX why is this implemented in C anyway?  Why not just use Mercury?
> > +concat_string_list(StringsList, _Len, String) :-
> > +	String = string__append_list(StringsList).
> 
> This Mercury implementation therefore has a very subtle bug.

Well, actually that code will work fine on .NET and Java,
since on those platforms, strings can contain embedded NUL characters.
And for the C and asm back-ends, the Mercury compiler will use the
C code for this procedure rather than the Mercury clauses.

I suppose there might potentially be problems with a future Mercury
back-end, if it has C-like strings but does not support the C interface.
But I don't think that's worth worrying about at the moment, is it?

> Stack_layout.m is used only with debugging and/or native-gc grades.
> Since native gc is not an option on .net and any debugging on .net
> will be totally different from the existing debugging infrastructure,
> the proper Mercury implementation should just abort with an error message.

Well, whatever grade the Mercury compiler is built in, it ought to be
able to cross-compile to different grades.

In practice it wouldn't really matter, unless we somehow manage to make
massive improvements in the efficiency of the `il' grade, since the
version of the Mercury compiler built in the `il' grade is slow enough
that it won't be used for anything other than testing the `il' grade
and benchmarking.

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
The University of Melbourne         |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.
--------------------------------------------------------------------------
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