I'm not sure if I'm missing something here. You don't want `in-vector` because you want to set the values of the vector, correct?

You can already do something very much like this with

```
(iter (for x in-vector *my-vector* with-index i)
   (incf (aref *my-vector* i) 10))
```

I think you could probably add `access` for yourself using the existing extension facilities of `iterate`. I would be reluctant to see this added to the core version of `iterate` without a lot of thought about how it interacts with other features, a very detailed implementation plan, etc.

ITERATE is a very core piece of code for those who use it, and only to be messed with after very deep thought, especially for things that are easy to implement on top of it.

On 5 Aug 2025, at 11:44, Felecarp wrote:

Hello all,

I am a newcomer in lisp. I hope the mailling list is a right channel to write this.

I imaginated a feature for iterate. A built-in clause that inserts a symbol-macro in iterate output. It seems useful to me because symbol-macros are elegant setf-able places.

Here is a clause named `ACCESS var IN-VECTOR v` with a symbol macro for var.

```
(defparameter *my-vector* (make-array 8
    :initial-contents (iter (for i from 1 to 8) (collect i)))

(print *my-vector*)
#(1 2 3 4 5 6 7 8)

(iter (access i in-vector *my-vector*)
  (incf i 10))

(print *my-vector*)
#(11 12 13 14 15 16 17 18)
```

The clause would be writen like this :

```
(defmacro-clause (ACCESS var IN-VECTOR v)
  "Access the elements of a vector"
  (let ((vect (gensym))
          (end (gensym))
          (index (gensym)))
    ‘(progn
       (with ,vect = ,v)
       (with ,end = (array-dimension ,vect 0))
       (for ,index from 0 to (1- ,end))
       (with-symbol-macro ,var (aref ,vect ,index)))))
```

I see no way to implement it without modifications in the iterate macro. But I think this can be implemented inserting a `symbol-macrolet ,(nreverse *symbol-macro-bindings*)` just after `let* ,(nreverse *bindings*)` in the iterate macro output.

I would like to try to implement it.

My questions :

1. Are they existing approaches to get the same result in iterate ?
2. Does some common lisp iteration systems already provides this feature in their built-ins clauses or in the extension mechanism ? 3. Does someone already tried to implement this kind of feature in iterate ? 4. What are the contributing guidelines on the common lisp gitlab repository ? I plan to imitate the current symbol naming, comment and commit style ; and writing the corresponding unit tests.

Reply via email to