Range's opSlice(/**/) function

monarch_dodra monarch_dodra at gmail.com
Wed Jul 11 00:01:51 PDT 2012


On Tuesday, 10 July 2012 at 21:51:44 UTC, Jonathan M Davis wrote:
> On Tuesday, July 10, 2012 23:35:02 monarch_dodra wrote:
>
> 1. In general, I wouldn't recommend not caring whether a 
> variable is a
> container or a range. It matters a great deal to the semantics 
> of what you're
> doing.
>
> 2. At this point, [] is primarily used for getting ranges from 
> containers, for
> slicing static arrays, and for array copy operations.
>
> a[] = b[];
>
> You can't depend on any range defining it. None of the isXRange 
> templates
> require it.
>
> That being said, there's no reason why at least some ranges 
> couldn't define it.
> However, it would probably have to be restricted to forward 
> ranges (making it
> the same as save), so you still wouldn't be able to just assume 
> that [] would
> work. And unless we add it to what isForwardRange requires, you 
> couldn't even
> rely on forward ranges having it, since it's not required of 
> them.
>
> - Jonathan M Davis

Thank you for your reply, it makes a lot of sense.




More information about the Digitalmars-d mailing list