Super-dee-duper D features

Bill Baxter dnewsgroup at billbaxter.com
Fri Feb 16 13:18:48 PST 2007


Bruno Medeiros wrote:
> Andrei Alexandrescu (See Website For Email) wrote:
>> Bill Baxter wrote:
>>>
>>> You're of course welcome to your opinion, but multiple assignment 
>>> exists in many languages.  So you're saying they're all wrong to have 
>>> such a feature?
>>
>> No. It's good to have multiple assignments; it's annoying that Perl 
>> prevents the option of grouping initializers with the data if I so 
>> wanted:
>>
>> my $a = e1, $b = e2, $c = e3;
>>
>> I was just opining that
>>
>> foreach (a ; e1) (a2 ; e2) {}
>>
>> is clearer than:
>>
>> foreach (a ; b) (e1 ; e2) {}
>>
>>
>> Andrei
>>
> 
> Ah, but then would you agree that your simultaneous foreach proposal
> would only serve the purpose of grouping variables next to their data?
> I.e., it wouldn't help in terms of simplifying code complexity (as it
> might happen in other languages, like Perl which you mentioned in
> another post), since D can currently do this:
> 
>   foreach (x,y ; transpose_view(reverse_view(foo),bar)
>     //then why not this too?!

Oh, I wasn't thinking D could actually do this already.  Is a generic 
transpose_view possible using a variadic opApply?  I don't think so but 
maybe I'm wrong.   You'd need
    int opApply( int delegate(Args...) body ) {
       . . .
    }

Does that work?

--bb



More information about the Digitalmars-d mailing list