@@ -1465,51 +1465,44 @@ module Knowledge : sig
14651465 val read : ?package : string -> string -> t
14661466 (* * [read ?package input] reads a full name from input.
14671467
1468- This function will parse the [input] and return a
1469- fully-qualified name that corresponds to the input, using
1470- [ package] as the currently opened package . The input syntax
1471- is {v
1468+ This function will parse the [input] and return a fully-qualified name
1469+ that corresponds to the input, using [package] as the currently opened
1470+ package. The input syntax is
1471+ {v
14721472 name = string, ":", string
14731473 | ":", string
14741474 | string
14751475 string = ?a sequence of any characters?
14761476 v}
14771477
1478-
1479- Not all characters in the [input] string are treated
1480- literally, the following two characters have a special
1481- interpretation:
1478+ Not all characters in the [input] string are treated literally, the
1479+ following two characters have a special interpretation:
14821480 - ['\\'] the escape character;
14831481 - [':'] the package separator character.
14841482
1485- The escape character disables a special interpretation of the
1486- consequent character. The package separator denotes the place
1487- in the input where the package name ends and the name part
1488- starts.
1489-
1490- If [package] is specified then it is treated literally (as in
1491- the [create] function). The same as in [create] it defaults to
1492- the ["user"] package.
1493-
1494- If [input] doesn't denote a fully qualified name (i.e., there
1495- is no [':'] special character in [input], then the read name
1496- is qualified with the passed [package], otherwise the package
1497- is defined by the [input].
1498-
1499- The function is expected to work with the output of the [show]
1500- function, so that for all [n], [read (show n) = n]. However,
1501- it is robust enough to accept any user inputs, even if it is
1502- not a well-formed input, e.g., when an escape character is
1503- used to escaped a non-special character or when input contains
1504- more than one unescaped separators. In case of invalid input,
1505- all special characters that doesn't make sense are treated
1506- literally and the first special [':'] denotes the end of the
1507- package field. If the input is not valid, then it is possible
1508- that [show (read s) <> s], since the output of [show] is
1509- always valid, e.g.
1510-
1511- [show@@read "hello:cruel:world" = "hello:cruel\\:world"]
1512- *)
1483+ The escape character disables a special interpretation of the consequent
1484+ character. The package separator denotes the place in the input where
1485+ the package name ends and the name part starts.
1486+
1487+ If [package] is specified then it is treated literally (as in the
1488+ [create] function). The same as in [create] it defaults to the ["user"]
1489+ package.
1490+
1491+ If [input] doesn't denote a fully qualified name (i.e., there is no
1492+ [':'] special character in [input], then the read name is qualified with
1493+ the passed [package], otherwise the package is defined by the [input].
1494+
1495+ The function is expected to work with the output of the [show] function,
1496+ so that for all [n], [read (show n) = n]. However, it is robust enough
1497+ to accept any user inputs, even if it is not a well-formed input, e.g.,
1498+ when an escape character is used to escaped a non-special character or
1499+ when input contains more than one unescaped separators. In case of
1500+ invalid input, all special characters that doesn't make sense are
1501+ treated literally and the first special [':'] denotes the end of the
1502+ package field. If the input is not valid, then it is possible that
1503+ [show (read s) <> s], since the output of [show] is always valid, e.g.
1504+
1505+ [show@@read "hello:cruel:world" = "hello:cruel\\:world"] *)
15131506
15141507 val show : t -> string
15151508 (* * [show name] is the readable representation of [name].
0 commit comments