What syntax support for SRFI 231? Bradley Lucier (27 Jan 2022 20:48 UTC)
Re: What syntax support for SRFI 231? Alex Shinn (27 Jan 2022 21:42 UTC)
Re: What syntax support for SRFI 231? Bradley Lucier (27 Jan 2022 22:55 UTC)
Re: What syntax support for SRFI 231? Bradley Lucier (10 Feb 2022 02:15 UTC)

Re: What syntax support for SRFI 231? Alex Shinn 27 Jan 2022 21:42 UTC

On Fri, Jan 28, 2022 at 5:49 AM Bradley Lucier <xxxxxx@math.purdue.edu> wrote:
>
> What syntax support should appear in SRFI 231, the followup to SRFI 179?
>
> I don't think much about syntax, so I'm not the right person to lead on
> this issue.
>
> Jens Axel Jens Axel Søgaard recommended SRFI 42-type comprehensions.  We
> haven't yet determined why SRFI 42's example programs don't run on
> Gambit, but perhaps it would be good to discuss before then how such
> comprehensions would look in use.

I suspect foof-loop will run on Gambit, and there was some interest in making
a SRFI of that for R7RS.  The syntax would probably look like:

(loop ((for elt multi-index (in-array array))))
   ... do something with elt and multi-index ...)

allowing destructuring the index:

(loop ((for elt (i j) (in-array array))))
   ...)

The destructured version is actually easier and faster to implement and
needs no additional support.  The opaque index object version needs index
cursors, which in a pinch can be implemented with interval-for-each and
call/cc, but it would be more convenient and probably efficient to provide
cursors in the SRFI.  I don't think you need to provide any specific syntax.

--
Alex