Thread overview | ||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
June 05, 2017 Compile-Time Sort in D | ||||
---|---|---|---|---|
| ||||
The crowd-edited (?) blog post exploring some of D's compile-time features is now live. Thanks again to everyone who helped out with it. The blog: https://dlang.org/blog/2017/06/05/compile-time-sort-in-d/ Reddit: https://www.reddit.com/r/programming/comments/6fefdg/compiletime_sort_in_d/ |
June 05, 2017 Re: Compile-Time Sort in D | ||||
---|---|---|---|---|
| ||||
Posted in reply to Mike Parker | On Monday, 5 June 2017 at 14:23:34 UTC, Mike Parker wrote:
> The crowd-edited (?) blog post exploring some of D's compile-time features is now live. Thanks again to everyone who helped out with it.
>
> The blog:
> https://dlang.org/blog/2017/06/05/compile-time-sort-in-d/
>
> Reddit:
> https://www.reddit.com/r/programming/comments/6fefdg/compiletime_sort_in_d/
Very nice post!
|
June 05, 2017 Re: Compile-Time Sort in D | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jon Degenhardt | On 6/5/2017 10:54 AM, Jon Degenhardt wrote:
> On Monday, 5 June 2017 at 14:23:34 UTC, Mike Parker wrote:
>> The crowd-edited (?) blog post exploring some of D's compile-time features is now live. Thanks again to everyone who helped out with it.
>>
>> The blog:
>> https://dlang.org/blog/2017/06/05/compile-time-sort-in-d/
>>
>> Reddit:
>> https://www.reddit.com/r/programming/comments/6fefdg/compiletime_sort_in_d/
>
> Very nice post!
It's also on Hacker News under "Compile-Time Sort in D".
|
June 05, 2017 Re: Compile-Time Sort in D | ||||
---|---|---|---|---|
| ||||
Posted in reply to Mike Parker | On Monday, 5 June 2017 at 14:23:34 UTC, Mike Parker wrote: > The crowd-edited (?) blog post exploring some of D's compile-time features is now live. Thanks again to everyone who helped out with it. > > The blog: > https://dlang.org/blog/2017/06/05/compile-time-sort-in-d/ > > Reddit: > https://www.reddit.com/r/programming/comments/6fefdg/compiletime_sort_in_d/ This is a great article, Mike! At the end I expected a reference to D's great template constraints [1], maybe it's still worth adding sth. like this to show how amazingly useful CTFE is? auto myRandomEngine(ulong m, ulong a, ulong c)(ulong seed) if (properLinearCongruentialParameters!(m, a, c)) { return seed; } void main() { static assert(!__traits(compiles, myRandomEngine!(1, 2, 3)(42))); myRandomEngine!(1UL << 32, 1664525, 1013904223)(42); } Or alternatively if you don't want to rewrite properLinearCongruentialParameters e.g. auto myRandomEngine(ulong m, ulong a, ulong c)(ulong seed) if (pLCP!(m, a, c)) { return seed; } template pLCP(ulong m, ulong a, ulong c) { enum pLCP = properLinearCongruentialParameters(m, a, c); } [1] https://dlang.org/spec/template.html#template_constraints |
June 06, 2017 Re: Compile-Time Sort in D | ||||
---|---|---|---|---|
| ||||
Posted in reply to Mike Parker | On Monday, 5 June 2017 at 14:23:34 UTC, Mike Parker wrote:
> The crowd-edited (?) blog post exploring some of D's compile-time features is now live. Thanks again to everyone who helped out with it.
>
> The blog:
> https://dlang.org/blog/2017/06/05/compile-time-sort-in-d/
>
> Reddit:
> https://www.reddit.com/r/programming/comments/6fefdg/compiletime_sort_in_d/
Ah Reddit... The article about the elegance of CTFE. Let's discuss the meaning of "enum" then...
|
June 06, 2017 Re: Compile-Time Sort in D | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jon Degenhardt | On Monday, 5 June 2017 at 17:54:05 UTC, Jon Degenhardt wrote:
>
> Very nice post!
Thanks! If it gets half as many page views as yours did, I'll be happy. Yours is the most-viewed post on the blog -- over 1000 views more than #2 (my GC post), and 5,000 more than #3 (A New Import Idiom).
|
June 06, 2017 Re: Compile-Time Sort in D | ||||
---|---|---|---|---|
| ||||
Posted in reply to Seb | On Monday, 5 June 2017 at 21:35:54 UTC, Seb wrote: > > This is a great article, Mike! Thanks! > At the end I expected a reference to D's great template constraints [1], maybe it's still worth adding sth. like this to show how amazingly useful CTFE is? It's a good idea! I don't think I'll and change it at this point, though. When I was rewriting the last section, I considered showing two versions of a templated function -- one that uses the validator in a constraint and one that uses it at runtime -- but I worried that would add more noise. The msg pragma and the writeln kept the focus more narrow (which is something that kept coming up in feedback). And at that point, I was ready to be done with it. I worked on that post for a significant chunk of two days. |
June 06, 2017 Re: Compile-Time Sort in D | ||||
---|---|---|---|---|
| ||||
Posted in reply to Mike Parker | On Monday, 5 June 2017 at 14:23:34 UTC, Mike Parker wrote: > The crowd-edited (?) blog post exploring some of D's compile-time features is now live. Thanks again to everyone who helped out with it. > > The blog: > https://dlang.org/blog/2017/06/05/compile-time-sort-in-d/ > > Reddit: > https://www.reddit.com/r/programming/comments/6fefdg/compiletime_sort_in_d/ Nice work, the reddit likes keep going up. Nothing new for D users, but by encapsulating CTFE in a bite-sized blog post, you've gotten some outsiders to pay attention. Just read perhaps the most ringing endorsement I've ever seen for D in the comments: "How do you explain that in D complex metaprogramming artifacts such as bitfields, regex engines, compile-time parser generators, checked integers, generic allocators, are readily available from a smaller community, when in C++ you need an article explaining what tricks to use to sort a list of integers at compile time?" https://www.reddit.com/r/programming/comments/6fefdg/comment/dijct48 |
June 07, 2017 Re: Compile-Time Sort in D | ||||
---|---|---|---|---|
| ||||
Posted in reply to Mike Parker | On Tuesday, 6 June 2017 at 01:08:45 UTC, Mike Parker wrote: > On Monday, 5 June 2017 at 17:54:05 UTC, Jon Degenhardt wrote: > >> >> Very nice post! > > Thanks! If it gets half as many page views as yours did, I'll be happy. Yours is the most-viewed post on the blog -- over 1000 views more than #2 (my GC post), and 5,000 more than #3 (A New Import Idiom). I was surprised it's so popular, as the proggit thread didn't do that great, but it did well on HN and I now see it inspired more posts for Rust (written by bearophile, I think) and Go, in addition to the Nim post linked here before: https://users.rust-lang.org/t/faster-command-line-tools-in-d-rust/10992 https://aadrake.com/posts/2017-05-29-faster-command-line-tools-with-go.html |
June 07, 2017 Re: Compile-Time Sort in D | ||||
---|---|---|---|---|
| ||||
Posted in reply to Mike Parker | On Monday, 5 June 2017 at 14:23:34 UTC, Mike Parker wrote: > https://dlang.org/blog/2017/06/05/compile-time-sort-in-d/ Seems like you have inspired people... http://blog.zdsmith.com/posts/compiletime-sort-in-nim.html |
Copyright © 1999-2021 by the D Language Foundation