# Stream-filter not in constant space?

**URL:** https://racket.discourse.group/t/stream-filter-not-in-constant-space/1643
**Category:** Questions & Answers
**Created:** [January 17, 2023, 6:33pm UTC](https://racket.discourse.group/t/stream-filter-not-in-constant-space/1643 "2023-01-17T18:33:20Z")
**Posts on this page:** 3
**Page:** 2

<div class="post-metadata">

### Author: ![sorawee](https://avatars.discourse-cdn.com/v4/letter/s/ea5d25/32.png) [@sorawee](https://racket.discourse.group/u/sorawee)
#### Post date: [February 16, 2023, 4:36pm UTC](https://racket.discourse.group/t/stream-filter-not-in-constant-space/1643/21 "2023-02-16T16:36:38Z")

</div>

The PR ([https://github.com/racket/racket/pull/4554](https://github.com/racket/racket/pull/4554)) was merged. The program in the OP should now run in constant space.

---

<div class="post-metadata">

### Author: ![joskoot](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/joskoot/32/1964_2.png) [@joskoot](https://racket.discourse.group/u/joskoot)
#### Post date: [February 17, 2023, 12:03am UTC](https://racket.discourse.group/t/stream-filter-not-in-constant-space/1643/22 "2023-02-17T00:03:30Z")

</div>

to @sorawee  
Does your PR also solve problems with stream-map, stream-fold, in-stream and the like?  
Jos

PS  
I do not advocate the overloading of the stream-type.  
In my humble opinion a list should not be a stream, as a string is not a list either.  
I assume the requirement of backward compatibility inhibits the reversal of the overloading.

---

<div class="post-metadata">

### Author: ![sorawee](https://avatars.discourse-cdn.com/v4/letter/s/ea5d25/32.png) [@sorawee](https://racket.discourse.group/u/sorawee)
#### Post date: [February 17, 2023, 3:05am UTC](https://racket.discourse.group/t/stream-filter-not-in-constant-space/1643/23 "2023-02-17T03:05:28Z")

</div>

I think you made it clear that you don’t want lists to be used as streams. My thoughts are:

1. Yes, I think the requirement of backward compatibility would inhibit any change there. Currently, it’s explicitly stated in the documentation that “plain lists can be used as streams”, so some users might rely on that behavior already.
2. On the other hand, I don’t think using lists as streams is relevant to the original issue that you brought up. If it’s a topic that you would like to discuss more, I would recommend creating a new thread, and use this thread to only talk about the unexpected space consumption.

I fixed all the issues that I know about `stream-map`. I am not aware of any issue with `stream-fold` and `in-stream`. If you do, please let me know.

[Previous page](https://racket.discourse.group/t/stream-filter-not-in-constant-space/1643.md?page=1)
