[m-users.] String comparison when compiling to C

Richard O'Keefe raoknz at gmail.com
Mon Aug 26 10:49:42 AEST 2024


It's not clear to me why S1 < S2 is any more or less type-specific
than compare(<, S1, S2).

On Sun, 25 Aug 2024 at 04:43, Sean Charles (emacstheviking)
<objitsu at gmail.com> wrote:
>
> Thank Zoltan.
>
> I am now using `ordering` in and `compare` for my code. I also have now found '3.5 The standard ordering' chapter and read it.
> Again, apologies for the noise, in my defence, chemotherapy followed by radiotherapy comes with a few side effects, fortunately one of them is liking Mercury more and more and making me hate my day job as a Django developer even worse :D haha
>
> Thanks again,
> Sean. (I think that's who I am...)
>
>
> > On 23 Aug 2024, at 12:35, Zoltan Somogyi <zoltan.somogyi at runbox.com> wrote:
> >
> >
> >
> > On Fri, 23 Aug 2024 12:15:24 +0100, "Sean Charles (emacstheviking)" <objitsu at gmail.com> wrote:
> >> % The builtin comparison operation on strings is also implementation
> >> % dependent. The current implementation performs string comparison using
> >> %
> >> % - C's strcmp() function, when compiling to C;
> >
> >> So what is the 'way' to do string comparisons?
> >
> > The compare predicate in the builtin module. That is what your initial quote
> > is referring to.
> >
> >> I find it odd in all the code I've written, I have never needed to do this before!
> >
> > Most of the time, when people compare strings in other languages,
> > they do it to implement operations such as maps from strings to other entities,
> > or sorting. In Mercury, the standard library provides all the usual such operations.
> > And since those operations are generic, i.e. they operate on values of any type,
> > their implementations use the generic compare predicate in the builtin module,
> > not type-specific operations such as < or >.
> >
> > Zoltan.
> >
> >
>
> _______________________________________________
> users mailing list
> users at lists.mercurylang.org
> https://lists.mercurylang.org/listinfo/users


More information about the users mailing list