TypeFunction example: ImplictConvTargets

claptrap clap at trap.com
Wed Oct 7 11:58:35 UTC 2020


On Wednesday, 7 October 2020 at 11:10:15 UTC, Andrei Alexandrescu 
wrote:
> On 10/7/20 4:49 AM, Patrick Schluter wrote:
>> On Wednesday, 7 October 2020 at 02:33:21 UTC, 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.
>> 
>> No, it's not. It's central to the argument.
>
> Then the argument is specious.
>
> I've been also tempted to do this on occasion to tilt a 
> comparison one way or another - take C++ without STL or Boost, 
> or Haskell without Prelude. The reality is these need to be 
> considered together. (Make a hashtable in C++, no standard 
> library allowed...)

If you're just asking is this easier in this language or that 
then it is unheplful to say no stdlib. But thats not whats going 
on here. You're comparing two language features within one 
language. The incubant feature has 20 years of library support 
behind it. The other does not.

Lets reverse the roles, say TF were invented first, and somebody 
was arguing for templates to be added now. The TP version would 
be a couple of stdlib calls and the template version a whole page.

Its a nonsense to make a comparison like that.

Maybe your "temptation too tilt" is at play here but you havent 
realised it yet?



More information about the Digitalmars-d mailing list