Lazy Literal Range: Stooid late-nite idea?
Nick Sabalausky
a at a.a
Sat Oct 8 20:06:21 PDT 2011
Suppose you want to search through a range (yea, really hypothetical so
far... ;) )
auto x = ["foo", "bar", "bat", "meow"].find("bar");
assert(x.front == "bar");
Great, right? But what about this?:
auto x = [runtimeExpressionA, runtimeExprB, runtimeExprC,
etc].find(blah);
Doable, but then *all* those expressions have to be evaluated even if the
desired element is one of the first few. What about a range literal, nice
and easy like array, but lazily evaluated? I'm not suggesting anything built
into the language, of course, just an easily instantiated library type.
Good idea? Not hard to make? Already exists? Usefulness likely killed by
delegate overhead?
More information about the Digitalmars-d
mailing list