Re: Ad hoc ranges

2011-01-22 Thread Tomek Sowiński
Andrei Alexandrescu napisał: > On 1/21/11 7:35 PM, Tomek Sowiński wrote: > > Andrei Alexandrescu napisał: > > > >>> Like I said, anything that doesn't bother to expose range-interfaced > >>> iterators and is not performance critical is > >>

Re: Ad hoc ranges

2011-01-21 Thread Andrei Alexandrescu
On 1/21/11 7:35 PM, Tomek Sowiński wrote: Andrei Alexandrescu napisał: Like I said, anything that doesn't bother to expose range-interfaced iterators and is not performance critical is considered a target for ad hoc ranges. Working with non-D libraries, or libraries ported to

Re: Ad hoc ranges

2011-01-21 Thread Tomek Sowiński
Andrei Alexandrescu napisał: > > Like I said, anything that doesn't bother to expose range-interfaced > > iterators and is not performance critical is > > considered a target for ad hoc ranges. Working with non-D libraries, or > > libraries ported to D but preservi

Re: Ad hoc ranges

2011-01-21 Thread Andrei Alexandrescu
by design lazy parameters (unlike vanilla delegates) don't work like closures. Still, even with the overhead and limitations the idiom is remarkably useful, especially in face of range-unfriendly libraries from outside D realm. Enjoy. What types of stuff do you need ad-hoc ranges for? What&

Re: Ad hoc ranges

2011-01-21 Thread Tomek Sowiński
zy > > parameters (unlike vanilla delegates) don't work like closures. Still, > > even with the overhead and limitations the idiom is remarkably useful, > > especially in face of range-unfriendly libraries from outside D realm. > > > > Enjoy. > > What types

Re: Ad hoc ranges

2011-01-20 Thread Jonathan M Davis
don't work like closures. Still, > even with the overhead and limitations the idiom is remarkably useful, > especially in face of range-unfriendly libraries from outside D realm. > > Enjoy. What types of stuff do you need ad-hoc ranges for? What's the use case? I've never actuall

Re: Ad hoc ranges

2011-01-20 Thread Jonathan M Davis
On Thursday, January 20, 2011 16:19:54 bearophile wrote: > Tomek Sowiñski: > > auto range(T, Whatever)(lazy bool _empty, lazy Whatever _popFront, lazy T > > _front) { > > I am not sure, but I think Andrei has deprecated the "lazy" attribute. In general or on a specific function? I'm pretty sure t

Re: Ad hoc ranges

2011-01-20 Thread Tomek Sowiński
bearophile napisał: > I am not sure, but I think Andrei has deprecated the "lazy" attribute. Yes, but AFAIR in favor of implicit conversions of expressions to parameterless delegates, which strengthens my little idiom. -- Tomek

Re: Ad hoc ranges

2011-01-20 Thread bearophile
Tomek Sowiñski: > auto range(T, Whatever)(lazy bool _empty, lazy Whatever _popFront, lazy T > _front) { I am not sure, but I think Andrei has deprecated the "lazy" attribute. Bye, bearophile

Ad hoc ranges

2011-01-20 Thread Tomek Sowiński
Doing my own deeds, I often found myself in need of writing up a range just to e.g. feed it into an algorithm. Problem is, defining even the simplest range -- one-pass forward -- is verbose enough to render this (correct) approach unprofitable. This is how I went about the problem: auto range(