Plan for InputRange?

Paul Backus snarwin at gmail.com
Wed Sep 29 02:06:16 UTC 2021


On Tuesday, 28 September 2021 at 15:07:59 UTC, Dukc wrote:
> What should we do about this? One could argue that `moveFront` 
> belongs to `InputAssignable` as opposed to `InputRange`, but I 
> think it would be too much breakage to change it like that 
> anymore.

Maybe `moveFront` could throw an exception at runtime if the 
wrapped range does not support it. Something like the following:

```d
override E moveFront()
{
     static if (__traits(compiles, r.moveFront))
         return r.moveFront;
     else
         throw new Exception("Cannot move the front of a `" ~ 
typeof(r).stringof ~ "`");
}
```

It's a stupid hack, but that may be the best way to work around a 
stupid design mistake like this.


More information about the Digitalmars-d mailing list