Re: [m-users.] String comparison when compiling to C
"Richard O'Keefe" <[email protected]> Mon, 26 Aug 2024 12:49:42 +1200
| Newsgroups | gmane.comp.lang.mercury.general |
|---|---|
| Message-ID | <CABcYAd+oisNhzH2vzecXXm8-GXg8PWPbfhLXz1FLJf7mXxrmKA@mail.gmail.com> |
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) <[email protected]> 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 <[email protected]> wrote: > > > > > > > > On Fri, 23 Aug 2024 12:15:24 +0100, "Sean Charles (emacstheviking)" <[email protected]> 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 > [email protected] > https://lists.mercurylang.org/listinfo/users _______________________________________________ users mailing list [email protected] https://lists.mercurylang.org/listinfo/users