Empowering foreach with multiple aggregates

Daniel Keep daniel.keep.lists at gmail.com
Sun Sep 9 05:24:14 PDT 2007



Janice Caron wrote:
> Wow! You're good!

He's downs.

>>   static if(isArray!(T)) alias typeof(T[0]) IT;
>>   else alias ParameterTypeTuple!(
>>     ParameterTypeTuple!(
>>       typeof(&T.init.opApply)
>>     )[0]
>>   )[$-1] IT;
> 
> Sorry to jump threads here, but this is a really good example of why
> alias dst=src; would be a good thing. It took me a long time and a lot
> of counting parantheses to figure out that IT was being defined!
> 
> Anyway - that is excellent.
> 
> I guess the next question would be, can this trick be built into the
> language in an easy-to-use way. Or in Phobos?

I suspect not unless Walter adds stackthreads/coroutines to it first.

Then again, since it's so clean to use:

  foreach (ref d, ref s; pair(dst, strng(src)))

It seems fine as a library method.

P.S. to downs: did you have that one lying around, or is this old work? :P

	-- Daniel



More information about the Digitalmars-d mailing list