when should ranges be static

Inkrementator invalid at invalid.org
Sun Feb 16 16:03:35 UTC 2025


On Saturday, 15 February 2025 at 19:21:33 UTC, monkyyy wrote:
> On Saturday, 15 February 2025 at 11:47:58 UTC, Inkrementator 
> wrote:
> Would you expect that style change would remove this flavor of 
> bugs? Do you think this is a compiler bug?
It looks similar to this: 
https://github.com/dlang/dmd/issues/17733 I don't know enough 
whether this warrants another bug report. In the blocked 
suggested PR, this seems to be related to dual-context stuff, so 
your intuition might've right in that regard.

Another suggestion that works is desugaring the eponymous 
template and putting the struct in the template namespace.
```
template split(alias F,R){
	auto split(R r){
		return splitter(r);
	}

	private struct splitter{
		R r;
		auto front()=>r.takeuntil(r.findnext!F);
		void popFront(){r=r.findnext!F;}
		bool empty()=>r.empty;
	}
}
```
>Would you expect that style change would remove this flavor of 
>bugs?

At least from spotchecking, this made most of the non-static 
structs work again after applying one of these transformations


More information about the Digitalmars-d-learn mailing list