Re: [m-users.] String comparison when compiling to C
"Sean Charles (emacstheviking)" <[email protected]> Fri, 23 Aug 2024 15:54:53 +0100
| Newsgroups | gmane.comp.lang.mercury.general |
|---|---|
| Message-ID | <[email protected]> |
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