TrapFlow - Pattern Matching Library

monkyyy crazymonkyyy at gmail.com
Mon Nov 10 14:38:33 UTC 2025


On Monday, 10 November 2025 at 10:35:42 UTC, Zenw wrote:
> On Sunday, 9 November 2025 at 17:36:27 UTC, monkyyy wrote:
>> On Sunday, 9 November 2025 at 10:40:36 UTC, Zenw wrote:
>>> Hello!
>>>
>>> I've created a pattern matching library for D. Still 
>>> experimental, but might be an interesting approach.
>>>
>>> https://github.com/Zero-error-no-warning/TrapFlow
>>
>> shouldnt you be using the lazy keyword in at least some of 
>> these headers?
>
> You're absolutely right, I completely forgot about using `lazy` 
> in `opCall`. Thanks a lot!
> It would be even better if the `$` symbol could be used inside 
> a function literal in `opIndex`...

opDollar can be thinly lowered to a type

```d
import std;

struct foo{
	struct dollar{}
	auto opDollar()=>dollar();
	int opSlice(int,dollar)=>1;
	int opSlice(dollar,int)=>2;
}
unittest{
	foo bar;
	bar[1..$].writeln;
	bar[$..1].writeln;
}
```


More information about the Digitalmars-d-announce mailing list