Super-dee-duper D features
Bruno Medeiros
brunodomedeiros+spam at com.gmail
Sun Feb 18 10:22:48 PST 2007
Bill Baxter wrote:
> 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
Oops, my mistake, that "since D can currently do this" is wrong.
It's not implementable, you need an actual iterator concept to do that,
but so does Andrei's simultaneous foreach
(news://news.digitalmars.com:119/45D48352.50802@erdani.org), so those
examples are comparable.
--
Bruno Medeiros - MSc in CS/E student
http://www.prowiki.org/wiki4d/wiki.cgi?BrunoMedeiros#D
More information about the Digitalmars-d
mailing list