Re: [m-users.] String comparison when compiling to C
"Zoltan Somogyi" <[email protected]> Fri, 23 Aug 2024 13:35:34 +0200 (CEST)
| Newsgroups | gmane.comp.lang.mercury.general |
|---|---|
| Message-ID | <[email protected]> |
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