D and Nim

Ary Borenszweig via Digitalmars-d digitalmars-d at puremagic.com
Sun Jan 4 17:56:20 PST 2015


On 1/4/15 9:27 PM, bearophile wrote:
> Walter Bright:
>
>> Nim:
>>
>>    for neighbour in nodes[nodeId].neighbours:
>>
>> D:
>>
>>    foreach(immutable route neighbour; nodes[nodeID].neighbours){
>>
>> Correctly written D:
>>
>>     foreach (neighbour; nodes[nodeID].neighbours){
>
> I don't agree, the good D way is:
>
> foreach (immutable neighbour; nodes[nodeID].neighbours) {
>
> D programmers should apply const/immutable to every variable that
> doesn't need to mutate.

Why?



More information about the Digitalmars-d mailing list