Closed iacore closed 5 months ago
For comparison, the following is what janet-pegdoc says about integer peg special patterns:
$ pdoc -d integer
`<n>` -- where <n> is an integer
For n >= 0, try to match n characters, and if successful, advance that many characters.
For n < 0, matches only if there aren't |n| characters, and do not advance.
For example, -1 will match the end of a string because the length of the empty string is 0, which is less than 1 (i.e. |-1| = 1 and there aren't
that many characters).
I changed the wording a bit. It still reads awkward but the meaning is clear.
I think that this line:
For example, -1 will match the end of a string.
should come right after this line:
If negative, matches if not that many characters and does not advance.
because -1
is an example of a negative number, while 0
is not.
I think it would be fine to address the case of 0
as the last line (or before the text having to do with negative integers), for example:
0 counts as a match but there is no advancing.
I changed the wording again
The latest looks much improved to me :)
reference: https://github.com/janet-lang/janet/pull/1187#issuecomment-1586490024