OCaml's syntax for string literals
let s = "..."
is explained in the manual at the expected position:
https://caml.inria.fr/pub/docs/manual-ocaml/lex.html#s:stringliteral
However, OCaml has an alternative syntax for string literals which is especially handy for regular expressions and multi-line strings:
let s = {|...|}
let s = {foo|...|foo}
Where is that documented?
You can compare strings with the usal comparison operators: = , <> , < , <= , > , >= . You can also use the compare function, which returns -1 if the first string is less than the second, 1 if the first string is greater than the second, and 0 if they are equal.
Strings. A string s of length n is an indexable and immutable sequence of n bytes. For historical reasons these bytes are referred to as characters. The semantics of string functions is defined in terms of indices and positions.
How do I combine two strings in Ocaml? The (^) binary operator concatenates two strings.
According to the lexical conventions of OCaml, characters different from \ and " can be enclosed in single quotes and appear in strings. The special characters \ and " are represented in these contexts by their escape sequences. The escape sequence \\ denotes the character \ and \" denotes the character " .
To answer this question myself, the syntax was originally described in the extensions chapter of the OCaml manual:
Thanks to glennsl and octachron for pointing this out.
Update: Meanwhile it has been moved to the expected, more visible, places:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With