On Sun, Nov 8, 2009 at 22:43, dsimcha <dsimcha@yahoo.com> wrote:

Hot off the press and VERY prototype-ish:

Code:
http://pastebin.com/m2087e524

Docs:
http://cis.jhu.edu/~dsimcha/unpackEnumerate.html

Cool! Thanks a lot.
 
I looked at opApply for D1 maybe two years ago, but never used it myself. I'll go and read this part of the docs.

*test it*

Hmm, I can get enumerate to work, but the Unpack part doesn't compile. It complains elem.at!(0) is not an lvalue.

You know, the Proxy part of std.range.zip is really annoying. I'd prefer zip to return std.typecons.Tuples, even if that means stopping at the shortest range. That's what other languages do and it seems enough for most uses.


Does this look like a good addition to std.range?  The elegance of it is it solves
the problem of providing syntactic sugar to ranges w/ zero ripple effects either
in the compiler or in the rest of Phobos.  I'll file it somewhere more official
after people review it a little and refine the idea, but I definitely think
something similar to this has a legit place in std.range.

If you're wondering how unpack works and don't want to grovel through all the
code, it's tons of string mixin magic.  That's about the only way I was able to
make it work.

I'll read it with pleasure(!). I'm there to learn anyway.Heck, I can't read my own string mixins a week after writing them, so it'll be a good exercise.

As to making it an addition to std.range, I'm all for it. If people don't want to use it because they are leery of using opApply, too bad for them. Your small benchmark was interesting: overhead exists, but it's not awful.

  Philippe