Super-dee-duper D features

Bruno Medeiros brunodomedeiros+spam at com.gmail
Fri Feb 16 02:13:45 PST 2007


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?!

And your proposal would only serve to simplify the above to this:

   foreach (x ; reverse_view(foo)) (y ; bar)
     //probably I could!

which IMO is negligible, and not worthy of adding such new syntax.


-- 
Bruno Medeiros - MSc in CS/E student
http://www.prowiki.org/wiki4d/wiki.cgi?BrunoMedeiros#D



More information about the Digitalmars-d mailing list