This Week in D
February 15, 2015
Welcome to This Week in D! Each week, we'll summarize what's been going on in the D community and write brief advice columns to help you get the most out of the D Programming Language.
The D Programming Language is a general purpose programming language that offers modern convenience, modeling power, and native efficiency with a familiar C-style syntax.
This Week in D has an RSS feed.
This Week in D is edited by Adam D. Ruppe. Contact me with any questions, comments, or contributions.
Last week's issue was cancelled due to the editor taking a sick day. This issue of This Week in D will cover major events from the preceding two weeks.
Statistics
In the community
DConf 2015
Early bird registration is open! For $250 in February only, you can register to attend DConf 2015 which will be held May 27-29 at Utah Valley University in Orem, Utah, in the United States.
The talk submission deadline is this month! If you have something to say about D at the conference, please submit soon!
A second call for proposals has been issued, let's make it a great conference together.
Hope to see you there!
Community announcements
See more at digitalmars.D.announce.
Significant Forum Discussions
- Testing package proposed for Phobos because testing ranges is difficult without mocks. std.internal.test.dummyrange already exists along with other testing libraries. A module was written for Walter's Sargon extension library.
- @trust is an encapsulation method, not an escape is a long thread prompted by a long bugzilla discussion about the use of @trusted in Phobos. @trusted is often used on small local functions to provide an escape from the @safe protections. These small functions are not really trusted on their own, but since they are highly limited in scope, their use at all possible points can be manually verified. This allows automatic @safe checking for most the function while allowing limited escapes. Walter argues this is incorrect and the correct way to use @trusted is to encapsulate the whole operation, so the usage of the function does not need to be checked. The discussion argued both cases are valid and reviewers need to check it on a case-by-case basis to see what is best. The discussion also turned to possible language changes to help make @trusted and @safe easier to use.
- Another idiom I wish were gone from phobos/druntime is a thread discussing the pros and cons of in contracts. Andrei argues the code is unnecessarily verbose, but is convinced that explicit contracts do carry other advantages. People argue the verbosity is just due to blindly applying style rules when they don't make sense.
- A safer interface for core.stdc proposes writing tiny wrappers for standard C functions to provide increased safety using D features such as array slices.
- Renaming DMD File Extensions from C to C++ discusses a longstanding minor annoyance: for historical reasons, dmd's C++ source code has .c file extensions. This would change it to .cpp. It is unclear if the change will happen, since dmd is being ported to D anyway.
- misplaced @trust? discusses a possible language change to make @trusted easier to use. It does not look like the change will happen.
- Git, the D package manager argues that git submodules can be used as a package manager. However, deficiencies in dependency management shoot the idea down.
See more at forum.dlang.org and keep up with community blogs at Planet D.
Tip of the week
Don't use the ~ operator in a call to writeln. Instead, pass the arguments separately:
writeln("hello " ~ yourname); // don't do this
writeln("hello ", yourname); // instead, do this.
The ~ operator (not to be confused with the ~= operator, which works differently) allocates an intermediate to hold the concatenated result. This is often very convenient, but also somewhat wasteful. writeln offers an alternative with more convenience and efficiency: its variadic argument list.
writeln (and similar functions like writefln, std.conv.text, and std.string.format) can take any number of arguments of any type. It will convert them to string automatically and write them out, generating a minimal number of intermediates. With most arguments, writeln will not allocate at all.
Simply changing your ~ to , in writeln calls can make your code more efficient at small cost.
If you'd like to submit a tip, email me.
Upcoming events
Learn more about D
To learn more about D and what's happening in D: