foreach syntax, std.mixin

Philippe Sigaud philippe.sigaud at gmail.com
Wed Nov 11 14:16:34 PST 2009


On Wed, Nov 11, 2009 at 17:44, Philippe Sigaud <philippe.sigaud at gmail.com>wrote:

> On Wed, Nov 11, 2009 at 16:48, dsimcha <dsimcha at yahoo.com> wrote:
>
>>  If you uncomment a /*ref*/ in there somewhere, which was leftover from a
>> compiler bug a long time ago, it seems to work.  The real problem is that
>> that bit
>> of cruft hasn't been removed from Phobos yet.
>>
>
So, it works. Thanks!

Strangely, on my computer it's frequently faster to use your enumerate than
a raw range (re: your speed tests). Is there something I don't get? I
thought (ie: read here) that opApply was slower than other means of
iteration?
My own enumerate, which produces a tuple(uint, T) as a lazy range is thrice
as slow :(


And, I just discovered that I can simply unpack a tuple with .field or
.expand.

auto t = tuple('a',1, 2.0);
int foo(char a, int b, double c) { return to!int(a) * b * to!int(c);}
foo(t.expand) ; // works.

Is that common knowledge? It'd be nice addition to the std.typecons docs.

 Gosh, when I think of the time I spent to find a way to extract this
information with template recursion, to map a n-ary function on
tuple-producing ranges. And all this time, I could have done tuple-mapping
as a simple map on "foo(a.expand)".
Time for some heavy refactoring...

  Philippe
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20091111/2fddddba/attachment.html>


More information about the Digitalmars-d mailing list