Does D have too many features?

Alex Rønne Petersen xtzgzorex at gmail.com
Mon Apr 30 08:13:02 PDT 2012


On 30-04-2012 12:18, foobar wrote:
> Meta comment: C++ is the spawn of the devil so I don't accept anything
> related to c++ as a valid argument.
>
> On Sunday, 29 April 2012 at 20:09:34 UTC, Alex Rønne Petersen wrote:
> [...]
>>>
>>> I have used D and didn't claim that foreach isn't useful.
>>> What I said that is that it belongs in the library, NOT the language.
>>
>> Yeah, we tried that in C++. It sucked.
>
> See meta comment above.
>
>>
>> The reason it works for many functional languages is that they have
>> even more terse syntax than D. It would suck to make foreach a
>> function in D.
>>
>
> D wants to support functional programming. That means we should provide
> whatever is necessary to write functional style code including foreach
> methods. IF D can't properly implement a FP foreach method (And IMO it
> *can*) than we have failed.

Of course it can, but not with type inference, unless you templatize it. 
That is:

void forEach(alias fun, R)(R range)
{
     // ...
}

enjoys type inference: forEach!(item => foo(item))(myRange);

But this doesn't:

void forEach(R)(R range, scope void delegate(ElementType!R) dg)
{
     // ...
}

This won't work: forEach(myRange, item => foo(item));

You have to do: forEach(myRange, (ElementType!(typeof(myRange)) => 
foo(item));

which, frankly, sucks.

>
>>>>
>>>>> * version - this does not belong in a programming language. Git
>>>>> is a much better solution.
>>>>>
>>>>
>>>> So you'd maintain a git branch for every OS if there is some small
>>>> part that is OS-dependent? I don't think that is a better approach at
>>>> all.
>>>
>>> It is far better than having a pile of #ifdef styled spaghetti code.
>>> I'd expect to have all the OS specific code encapsulated separately
>>> anyway,
>>> not spread around the code base. Which is the current recommended way of
>>> using
>>> versions anyway. The inevitable conclusion would be to either use a
>>> version management system like git or have separate implementation
>>> modules for platform specific code and use the build tool to implement
>>> the logic of select the modules to include in the build.
>>
>> Yeah, we tried that in C and C++. It sucked. See: Autotools.
>>
>
> see meta comment above.
> The fact that you used a horribly designed language with a horrible mess
> of a "build tool" made out of shell scripts IIRC is not an indication
> that the language should include build-tool functionality.
>


-- 
- Alex


More information about the Digitalmars-d mailing list