GNU bug report logs -
#73431
Add `setf` support for `stream.el` in ELPA
Previous Next
Reported by: Okamsn <okamsn <at> protonmail.com>
Date: Mon, 23 Sep 2024 01:35:01 UTC
Severity: wishlist
Done: Stefan Monnier <monnier <at> iro.umontreal.ca>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
Stefan Monnier wrote:
>>> +(defun \(setf\ stream-first\) (store stream)
>>> + "Set the first element of STREAM to value STORE."
>>> + (if (stream-empty-p stream)
>>> + (error "Cannot set first element of empty stream: %s" stream)
>>> + (setcar (stream--force stream) store)))
>>
>> I am not sure what the preferred practice to define generalised setters
>> is. In gv.el everything is defined using `gv-define-simple-setter' or
>> `gv-define-setter', which /feels/ more robust? I believe that Stefan
>> (as the author or gv.el) might be able to explain if this is so or not.
>
> Defining \(setf\ FOO\) looks fine to me 🙂
> I'm not sure we want to make streams mutable, OTOH.
> Is there a known use-case for it?
>
>
> Stefan
>
Hello,
Currently, using `(setf (seq-elt STREAM 0) VAL)` silently fails, because
it treats the stream as a list, breaking the stream.
On the desire for mutability, there is the included macro `stream-pop`.
My use case is mainly consistency. I am currently cleaning up support
for destructuring generic sequences with generalized variables in my
package, which is how I noticed the silent failure for streams. I have
found streams useful for iterating over sub-sequences of vectors, like
what `cl-maplist` does with lists.
Thank you.
This bug report was last modified 264 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.