TypeFunction example: ImplictConvTargets

Timon Gehr timon.gehr at gmx.ch
Wed Oct 7 13:31:16 UTC 2020


On 07.10.20 04:33, Andrei Alexandrescu wrote:
> On 10/6/20 9:07 PM, claptrap wrote:
>> On Tuesday, 6 October 2020 at 23:39:24 UTC, H. S. Teoh wrote:
>>> On Tue, Oct 06, 2020 at 11:16:47PM +0000, claptrap via Digitalmars-d 
>>> wrote: [...]
>>>>
>>> I would write it like this:
>>>
>>>     int[] vals = [4,7,28,23,585,73,12];
>>>
>>>     int[] getMultiplesOf(int i)
>>>     {
>>>         return vals.filter!(v => (v % i) == 0).array;
>>>     }
>>>
>>> One line vs. 4, even more concise. ;-)
>>
>> The point is to show language not library.
> 
> That's a made-up restriction, and it's odd that it is being discussed 
> here as a virtue.
> ...

I agree. This is a bad way to market a new language feature. However, I 
don't think "library over language" is necessarily a good justification 
for an inefficient implementation of core language features.

> Beginners are attracted to large languages that have everything built in.

Isn't it rather that beginners can't tell the difference?

> A good language is focused on general primitives that allow writing 
> a great deal in libraries.
> 
> 

Certainly, but a good language does not require you to write the same 
functionality multiple times.


More information about the Digitalmars-d mailing list