std.v2020.algorithm etc[ WAS: Is run.d going to be expand for runtime and the phobos library?]

Petar Petar
Sat Jun 20 12:57:25 UTC 2020


On Saturday, 20 June 2020 at 12:42:01 UTC, Stanislav Blinov wrote:
> On Saturday, 20 June 2020 at 10:43:41 UTC, Paul Backus wrote:
>
>> Also, switch from `void popFront()` to `typeof(this) rest`, so 
>> that we can have `const` and `immutable` ranges.
>
> *Switch* is probably too restrictive. For a given range a 
> `popFront` may be more efficient than a `range = range.rest`. 
> Making `rest` a valid range primitive though, and using where 
> appropriate - that'd be awesome.

Yes, that may be a valid concern, I have thought about this as 
well.

The main issue is for some kinds of iterables, like alias 
sequences, we have no choice but to use an immutable-friendly API 
like rest/dropOne or concat (not append). A couple of years ago I 
was able to write proof-of-concept library that had accumulate, 
map, and filter implementations that worked with both ranges and 
template parameter sequences, based on immutable-friendly 
functions like this

See:

https://github.com/PetarKirov/rxd/blob/v0.0.3/source/rxd/xf/xform.d

Some of the technics that I had developed allowed me to implement 
UFCS-enabled alternatives to std.meta that accept a polymorphic 
lambda parameter for mapping/filtering/etc.:

https://gist.github.com/PetarKirov/a808c94857de84858accfb094c19bf77



More information about the Digitalmars-d mailing list