Semantics of char-set-cursor-next
Bradley Lucier 10 Jul 2023 02:19 UTC
The signature is
char-set-cursor-next cset cursor -> cursor
The SRFI text says:
========================
A cursor index is incremented with char-set-cursor-next; in this way,
code can step through every character in a char set.
========================
I don't have much experience with cursors. I want to know whether
char-set-cursor is allowed to modify the "cursor" argument it is passed.
I ask because in my design the cursor is a vector of three elements, but
with very fast increment (on average) if I can modify the cursor argument.
Here's what some web pages say about char-set-cursor-next.
http://marcomaggi.github.io/docs/vicare-libs.html/srfi-char_002dsets-spec-iter.html
========================
char-set-cursor-next increments a cursor index and returns a new cursor
indexing the next character in the set; in this way, code can step
through every character in a char set.
========================
I assume this means that the argument cursor is not modified. The code
in lib/vicare/containers/char-sets.vicare.sls seems not to modify the
cursor, but to build an entirely new one.
https://www.gnu.org/software/guile/manual/html_node/Iterating-Over-Character-Sets.html
========================
Scheme Procedure: char-set-cursor-next cs cursor
C Function: scm_char_set_cursor_next (cs, cursor)
Advance the character set cursor cursor to the next character in
the character set cs. It is an error if the cursor given satisfies
end-of-char-set?.
========================
This sounds like the argument cursor is modified. The code in
libguile/srfi-14.c seems to modify the argument.
I don't understand the code in gnu/kawa/slib/srfi14.scm to know what
Kawa does (it appears that the cursor is an integer, though, so it
wouldn't change the argument).
Brad