Proposed Changes to the Range API for Phobos v3

monkyyy crazymonkyyy at gmail.com
Thu May 16 17:05:56 UTC 2024


On Thursday, 16 May 2024 at 14:56:55 UTC, Jonathan M Davis wrote:
> wall-o-text
> no function header lists or patterns

????

> no reference at all to keyed ranges

????

> explict range starters for unicode instead of autodecoding

ok, thats *half* the problem; how does `hello 😀 
world`.byUnicode(flag.charIndex).indexOf('w')` count correctly? 
The existing range api discards information that is otherwise 
trivial to have

the old solution of dchars and autodecoding failed; whats your 
proposal for the unicode problem on the *dchar* side of the 
problem where it was believed that dchar would simplify all use 
cases of unicode into simple indexing

> There is no guarantee that the init value of a range is even 
> valid

Thats not what init means in this language; I believe it should 
be `.zero`, optional and part of a larger change were float.zero 
is 0.0; see my dip

> 8. $ cannot be used with random-access ranges in generic code, 
> because the range API does not require that a random-access 
> range define opDollar

I believe you should be much much much more spefic

is [min(i,$-1)] supported? is [$..0] supported?

the slicing api is a rabbit hole that needs allot of care


More information about the Digitalmars-d mailing list