On 2019-12-27 17:54:28 +0000, Steven Schveighoffer said:
This is the rub with ranges. You need to use typeof. There's no other way to do it, because the type returned by byGrapheme depends on the type of Range.
Hi, ok, thanks a lot and IMO these are the fundamental important information for people using D (beginners, causual programmers, etc.) to understand how things fit together.
If you know what type Range is, it would be: struct S { typeof(string.init.byGrapheme()) gText; // or alias GRange = typeof(string.init.byGrapheme()); GRange gText; }
Ah... I didn't know that I can use a basic type "string" combined with ".init" to manually build the type. Neat...
Subbing in whatever your real range for `string`. Or if it's the result of a bunch of adapters, use the whole call chain with typeof.
Ok, and these are good candidates for alias definitions to avoid re-typing it many times.
Why not just declare the real range type? Because it's going to be ugly, especially if your underlying range is the result of other range algorithms. And really, typeof is going to be the better mechanism, even if it's not the best looking thing.
I think I got it... thanks a lot. -- Robert M. Münch http://www.saphirion.com smarter | better | faster