May 20, 2019

Posted 2019-05-20

I tried to improve cgi.d's build time, but it refused to budge; in this case, Phobos dependency was not to blame, so I have to keep trying things. (It is amazing how much D spoils us; this 2 second complete rebuild from scratch feels soooo slow.)

Core D Development Statistics

In the community

Community announcements

See more at the announce forum.

Tip of the Week

While experimenting with my compile speed tweaks, I had to make local variables in a static foreach thing, while avoiding the conflict.

static foreach(i; [1, 2, 3]) {
    int b = i;

Often, we'd suggest putting an extra scope around it - use {{ ... }}. But if you do need to make a public declaration with those pieces, that doesn't help much.

This time, I used a local template:

1 template Locals(int i) {
2     alias Whatever = int;
3 }
5 static foreach(i; [1, 2, 3]) {
6    Locals!i.Whatever;
7 }

I only briefly played with this; since my refactor failed to produce the desired results, I undid all the changes. But this particular approach seemed to work (my test case still compiled, at least) and thus plausible to revisit in the future.

A random thought

D supports delimited strings:

1 string s = q"html
2   <html>
3   <head></head>
4   </html>
5 html";

I recently changed my editor to recognize that pattern as an embedded language, and syntax highlight it appropriately. I might do the same with adrdox in the future.

Not sure how valuable that will be yet, but I'll let you know as I gain more experience with it.