Semantics of char-set-cursor-next Bradley Lucier (10 Jul 2023 02:20 UTC)
Re: Semantics of char-set-cursor-next Marc Feeley (10 Jul 2023 07:21 UTC)
Re: Semantics of char-set-cursor-next Marc Nieper-Wißkirchen (10 Jul 2023 09:40 UTC)
Re: Semantics of char-set-cursor-next Marc Nieper-Wißkirchen (10 Jul 2023 09:41 UTC)
Re: Semantics of char-set-cursor-next Bradley Lucier (10 Jul 2023 19:34 UTC)

Re: Semantics of char-set-cursor-next Marc Nieper-Wißkirchen 10 Jul 2023 09:40 UTC

Am Mo., 10. Juli 2023 um 11:39 Uhr schrieb Marc Nieper-Wißkirchen
<xxxxxx@gmail.com>:
>
> The procedure har-set-cursor is (fortunately!) not allowed to modify

char-set-cursor-next

> its argument.
>
> This is from SRFI 14:
>
> **
> The procedures of this SRFI, by default, are "pure functional" -- they
> do not alter their parameters. However, this SRFI defines a set of
> "linear-update" procedures which have a hybrid
> pure-functional/side-effecting semantics: they are allowed, but not
> required, to side-effect one of their parameters in order to construct
> their result. An implementation may legally implement these procedures
> as pure, side-effect-free functions, or it may implement them using
> side effects, depending upon the details of what is the most efficient
> or simple to implement in terms of the underlying representation.
>
> The linear-update routines all have names ending with "!".
> **
>
> In particular, a version that allowed the modification of an argument
> would have been called char-set-cursor-next!.
>
> NB The sentence "Note that these primitives are necessary to export an
> iteration facility for char sets to loop macros." shows the deficiency
> of RnRS for n <= 7 in that it has no delimited continuations. Such
> primitives should not be necessary, and they wouldn't be with
> delimited continuations.
>
> Am Mo., 10. Juli 2023 um 04:20 Uhr schrieb Bradley Lucier <xxxxxx@purdue.edu>:
> >
> > 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