[m-rev.] diff: implement concat_string_list for .NET
Fergus Henderson
fjh at cs.mu.OZ.AU
Mon Feb 17 22:37:09 AEDT 2003
On 17-Feb-2003, Zoltan Somogyi <zs at cs.mu.OZ.AU> wrote:
> On 16-Feb-2003, Fergus Henderson <fjh at cs.mu.OZ.AU> wrote:
> > + % This type is for strings which may contain embedded null characters.
> > +:- type string_with_0s ---> string_with_0s(string).
>
> This is wrong. If you define an abstract data type, it must contain not only
> the character array ("string") but also its length.
That would probably be an improvement. Feel free to make it.
I didn't want to change the structure of the code significantly --
I was effectively just adding some comments, in a way that the
compiler could check.
> > +% This version is only used if there is no matching foreign_proc version.
> > +% Note that this version only works if the Mercury implementation's
> > +% string representation allows strings to contain embedded null
> > +% characters. So we check that.
> > +concat_string_list(StringsList, _Len, string_with_0s(StringWithNulls)) :-
> > + (
> > + char__to_int(NullChar, 0),
> > + NullCharString = string__char_to_string(NullChar),
> > + string__length(NullCharString, 1)
> > + ->
>
> I don't believe this test will succeed on any version of the current Mercury
> implementation.
It succeeds on the .NET back-end. It should succeed on the Java
back-end too, once the relevant procedures such as string__length
are implemented for Java.
> The reason why I used C code to do the concatenation in the first place
> is that with a very few exceptions (such as string__index), the predicates
> in the string module all assume that strings are null terminated.
> String__length certainly does.
The C implementations of those predicates do.
But the .NET implementations don't.
--
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