Why are homepage examples too complicated?

Chris via Digitalmars-d digitalmars-d at puremagic.com
Thu Oct 20 07:23:38 PDT 2016


On Thursday, 20 October 2016 at 14:04:06 UTC, Andrei Alexandrescu 
wrote:
> On 10/20/2016 07:38 AM, Nick Treleaven wrote:
>> On Sunday, 16 October 2016 at 16:07:19 UTC, Nick Treleaven 
>> wrote:
>>> I think this example is a bit awkward for D newbies to 
>>> decipher. I
>>> think here we are showing D's ctRegex; dropping the 
>>> functional map and
>>> lambdas would make this more universally understood.
>>
>> https://github.com/dlang/dlang.org/pull/1500
>
> I think it would be best if we kept both. -- Andrei

Actually, the whole example would be easier to understand, if 
there were more comments. I.e. explain what `pipe!` does and what 
`ctRegex` is.

It's much clearer in the Docs[1]:

// Read an entire text file, split the resulting string in
// whitespace-separated tokens, and then convert each token into 
an
// integer
int[] a = pipe!(readText, split, map!(to!(int)))("file.txt");

In general I find it helpful, when there are comments in example 
snippets. Some examples from the Docs would actually be quite 
good for newbies. Maybe we can harvest snippets there.


[1] http://dlang.org/phobos/std_functional.html#.pipe


More information about the Digitalmars-d mailing list