The new, new phobos sneak preview
Andrei Alexandrescu
SeeWebsiteForEmail at erdani.org
Mon Apr 13 19:13:53 PDT 2009
Daniel Keep wrote:
> Actually, I've been thinking and I realised that in 95% of cases, you
> can assume a range is resumable if it has no references.
Well I'm not so sure. How about a range around an integral file handle
or socket?
> If it has no
> references, the only way the range can be non-resumable is if the
> advance member uses the range's state as an argument to some global
> method. An example might be a Range that statically accesses Stdout
> instead of taking it as an argument.
>
> It's a real shame the range interface doesn't support this:
>
>> struct R
>> {
>> ...
>> pure R advance();
>> }
>
> If it did, we could prove a range was resumable if advance was pure and
> R has no mutable or const references.
Hmmmm... well, pure changes "this". We'd need to say that it only
changes state owned by "this", but we have no notion of "almost pure".
> Honestly, I think the safest option is to *require* resuming to be
> explicitly stated by the programmer. It'd be nice if we could
> automatically account for some cases, but I can't think of any you
> couldn't escape from.
>
> Maybe we should default to non-resumable for now, then re-visit the
> issue when we have an idea of how people are using ranges.
I agree. Probably I'll do that, thanks.
By the way, Walter and I both changed the names of the members to what
everybody seemed to liked best: front, back, popFront, popBack. No more
heads and toes.
Andrei
More information about the Digitalmars-d
mailing list