foreach syntax, std.mixin

Philippe Sigaud philippe.sigaud at gmail.com
Wed Nov 11 06:38:40 PST 2009


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

>
> Hot off the press and VERY prototype-ish:
>
> Code:
> http://pastebin.com/m2087e524
>
> Docs:
> http://cis.jhu.edu/~dsimcha/unpackEnumerate.html<http://cis.jhu.edu/%7Edsimcha/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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20091111/f95020e2/attachment.html>


More information about the Digitalmars-d mailing list