Super-dee-duper D features

Andrei Alexandrescu (See Website For Email) SeeWebsiteForEmail at erdani.org
Wed Feb 14 00:09:09 PST 2007


Bill Baxter wrote:
> Andrei Alexandrescu (See Website For Email) wrote:
>> Bill Baxter wrote:
>>> Andrei Alexandrescu (See Website For Email) wrote:
>>>
>>>
>>>> I'm actually mildly surprised. Lately there was some talk around 
>>>> here about supporting the day-to-day programmers and so on. I find 
>>>> looping a very day-to-day thing, and looping over 2+ things at least 
>>>> a few-days-to-few-days thing. There is a need for parallel 
>>>> iteration, if nothing else shown by the existence of a library that 
>>>> addresses exactly that - to the extent possible in a library that's 
>>>> not in the position to control syntax, scoping, and visibility. I 
>>>> was sure people will be on this one like white on rice. But Bjarne 
>>>> Stroustrup was right: nobody knows what most programmers do :o).
>>>
>>> Python and Ruby are hardly considered to be obtuse languages, or 
>>> unfriendly to Joe coder, but both get by just fine without special 
>>> case syntax for iterating over multiple collections, or for iterating 
>>> in reverse.
>>>    for x,y izip(foo,bar):
>>>        do stuff
>>>
>>>    for x reversed(foo):
>>>        do stuff
>>>
>>>    for x,y izip(reversed(foo),bar):
>>>        do that with your proposal!
>>
>> foreach (x ; reverse_view(foo)) (y ; bar)
>>   probably I could!
> 
> foreach (x,y ; transpose_view(reverse_view(foo),bar)
>   then why not this too?!

Because it doesn't keep bound variables together with the data. Perl has 
a way of initializing multiple variables that is unnerving:

my ($a, $b, $c) = (e1, e2, e3);

The long-distance relationships make it so irritating when ek are more 
than a couple of characters, I often give up and write:

my $a = e1;
my $b = e2;
my $c = e3;

even though I try to use vertical space sparingly.


Andrei



More information about the Digitalmars-d mailing list