A problem in converting C code

Ali Çehreli acehreli at yahoo.com
Wed Nov 3 02:41:02 UTC 2021


On 11/2/21 6:49 PM, zjh wrote:
> On Tuesday, 2 November 2021 at 23:02:42 UTC, Ali Çehreli wrote:
>> On 11/2/21 3:57 PM, Ali Çehreli wrote:
> 
>>   const x = readln.strip;
> 
> this is very interesting .`readln` then `strip;`,Very natural.
> 
> 

Yes, UFCS (universal function call syntax) makes code natural, concise, 
and readable (but things can get out of hand :) ).

Here is an example copied from the home page of dlang.org:

import std.stdio, std.array, std.algorithm;

void main()
{
     stdin
         .byLineCopy
         .array
         .sort!((a, b) => a > b) // descending order
         .each!writeln;
}

Ali



More information about the Digitalmars-d-learn mailing list