This is the homepage of Peter Alexander. I am currently at Facebook working on AR/VR. Any opinions are my own.
Recent Posts
- Single-Threaded Parallelism
- unique_ptr Type Erasure
- The Condenser Part 1
- Cube Vertex Numbering
- Range-Based Graph Search in D
All Posts
Links
github.com/Poita@Poita_
Atom Feed
Scoped Imports in D
Posted: 2012-01-26 - Link
One of the nice things about the D programming language is that it has very convenient syntax for conditional compilation. For example, suppose you want to print out some useful info in debug builds. You just use:
One problem that I constantly run into in cases like this is that I
haven’t import
ed std.stdio
, so I have to go right up to the top of
the file, add debug import std.stdio;
, back down again, and continue.
Sigh.
Not so fast! D has scoped imports, so you can put the import
std.stdio;
right where you need it.
It’s the little things like this that make D so pleasant to use.