[m-rev.] for review: mercury implementation of string.m
Peter Ross
pro at missioncriticalit.com
Sat Jun 15 18:40:45 AEST 2002
On Sat, Jun 15, 2002 at 06:39:46AM +1000, Simon Taylor wrote:
> On 14-Jun-2002, Peter Ross <pro at missioncriticalit.com> wrote:
> > > > +:- pragma promise_pure(string__length/2).
> > > > +string__length(Str::in, Len::uo) :-
> > > > + string__length_2(Str, Len).
> > > > +string__length(Str0::ui, Len::uo) :-
> > > > + copy(Str0, Str),
> > > > + string__length_2(Str, Len).
> > > > +
> > > > +:- pred string__length_2(string::in, int::uo) is det.
> > > > +string__length_2(Str, Length) :-
> > > > + ( string__first_char(Str, _First, Rest) ->
> > > > + string__length(Rest, Length0),
> > > > + Length = Length0 + 1
> > > > + ;
> > > > + Length = 0
> > > > + ).
> > >
> > > It would be better to just call `sorry' here.
> > >
> > No I think it is better to have a Mercury version even if it very
> > inefficient.
>
> That isn't just very inefficient, it's ridiculously inefficient.
>
This one I rewrote in terms of string__index.
--------------------------------------------------------------------------
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