Prime sieve language race

Bastiaan Veelo Bastiaan at Veelo.net
Tue Jul 13 19:06:12 UTC 2021


On Sunday, 4 July 2021 at 22:35:44 UTC, SealabJaster wrote:
> On Sunday, 4 July 2021 at 15:31:31 UTC, Bastiaan Veelo wrote:
>> ...
>
> Decided to give it a go. Faithful but is slightly more D-ish 
> https://github.com/PlummersSoftwareLLC/Primes/pull/292

Merged here:
https://github.com/PlummersSoftwareLLC/Primes/tree/drag-race/PrimeD/solution_2

I like it! A few points:

1. The output in the readme shows `Valid: false`, which worries 
me. I didn't try your solution myself yet.
2. Not sure if this was clearly stated in the rules, but he [says 
that the sieve size must be a run time 
value](https://youtu.be/Yl9OegOorYM?t=532). I hope this doesn't 
disqualify your solution.

Further some nit-picks, feel free to ignore:

3. Line 23 `// it also allows D to write more "file-portable" 
code.` Not sure what you mean by this. Worth noting however is 
that the import only happens iff the template is instantiated, 
which is nice.
4. Line 38: Did you mean to leave `(citation needed)` in there?
5. `printResults` can be made `@safe` by means of a nested 
`@trusted` wrapper 
([ref](https://forum.dlang.org/post/pvadtwqblgclttzesxeg@forum.dlang.org)):
```d
     // If not called from multiple threads, this can be trusted.
     static File trustedStderr() @trusted
     {
         return stderr;
     }
```

Out of curiosity, do you know how your solution compares with the 
first one performance wise, roughly?

Thanks for your submission!

-- Bastiaan.


More information about the Digitalmars-d mailing list