Here we give the. implementation of Name.toString. There is also a private implementation in
Init.Meta, which we cannot import this implementation due to import hierarchy limitations.
The difference between the two versions is that the one in Init.Meta uses the String.Internal.*
functions, while the one here uses the public String functions. These differ in
that the latter versions have better inferred borrowing annotations, which is significant for an
inner-loop function like Name.toString.
Creates a round-trippable string name component if possible, otherwise returns none.
Names that are valid identifiers are not escaped, and otherwise, if they do not contain », they are escaped.
- If
forceistrue, then even valid identifiers are escaped.
Equations
Instances For
Uses the separator sep (usually ".") to combine the components of the Name into a string.
See the documentation for Name.toStringWithToken for an explanation of escape and isToken.
Equations
Instances For
Converts a name to a string.
- If
escapeistrue, then escapes name components using«and»to ensure that those names that can appear in source files round trip. Names with number components, anonymous names, and names containing»might not round trip. Furthermore, "pseudo-syntax" produced by the delaborator, such as_,#0or?u, is not escaped. - The optional
isTokenfunction is used whenescapeistrueto determine whether more escaping is necessary to avoid parser tokens. The insertion algorithm works so long as parser tokens do not themselves contain«or».
Equations
Instances For
Converts a name to a string.
- If
escapeistrue, then escapes name components using«and»to ensure that those names that can appear in source files round trip. Names with number components, anonymous names, and names containing»might not round trip. Furthermore, "pseudo-syntax" produced by the delaborator, such as_,#0or?u, is not escaped.