> You don't want in-vector because you want to set the values of the vector, > correct?
I want to write clauses with symbol macros, because they are more concise setf able places. I want to add `with-symbol-macro`, not `access`. `Access` is just a simplified example of the kind of facilities `with-symbol-macro` enables. > I think you could probably add access for yourself using the existing >extension facilities of iterate. Great! Could you explain how to write the access clause using the existing extension facilities of Iterate? I couldn't find this feature in the documentation. I didn't find any ideas while reading the iterate.lisp code either, unless I add `with-symbol-macro` to iterate. The most satisfying solution I can come up with for now, without modifying iterate, is to pass the accessor expression into a special variable and evaluate it using a custom setf expansion. This can solve my original problem, but I was hoping for a more elegant solution. (require "iterate") (use-package (find-package "ITERATE")) (defvar *accessors*) (defmacro with-access-clauses (&body body) `(let ((*accessors* nil)) ,@body)) (defmacro-clause (ACCESS var IN-VECTOR v) "Access the elements of a vector" (let ((vect (gensym)) (index (gensym)) (accessor-pair (gensym)) (accessor-value (gensym))) `(progn (with ,vect = ,v) (for ,var in-vector ,vect with-index ,index) (let ((,accessor-value (list 'aref ,vect ,index)) (,accessor-pair (assoc ',var *accessors*))) (if ,accessor-pair (setf (cdr ,accessor-pair) ,accessor-value) (push (cons ',var ,accessor-value) *accessors*)))))) (define-setf-expander access (x &environment env) (multiple-value-bind (dummies vals newval setter getter) (get-setf-expansion x env) (let ((store (gensym))) (values dummies vals `(,store) `(eval `(setf ,(cdr (assoc ',x *accessors*)) ,,store)) `(eval (cdr (assoc ',x *accessors*))))))) (let ((vect #(1 2 3 4 5 6))) (with-access-clauses (iter (access i in-vector vect) (incf (access i) 10))) (print vect)) > 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. Yes, I understand that you are cautious about merging code that modifies the core of Iterate. Precautions are indeed necessary to protect users from any potential side effects. Thank you for your response and attention to this. 5 août 2025, 21:32 de rpgold...@sift.info: > > 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 : >> >> Are they existing approaches to get the same result in iterate ? >> Does some common lisp iteration systems already provides this feature in >> their built-ins clauses or in the extension mechanism ? >> Does someone already tried to implement this kind of feature in iterate ? >> 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. >>