Download Reference Manual
The Developer's Library for D
About Wiki Forums Source Search Contact

Frequently Asked Questions

Last edited: 16th of December, 2008

This page is mostly about frequently asked questions about Tango, but may also include more general D questions. For now all questions are kept on one page, but if it grows wildly it may be split into subpages.

Console IO

  • Q: How can I redirect the console output?
  • A: The associated stream can be reassigned. It's possible to redirect the lowest level (Cout/Cerr) or only the formatted output (Stdout/Stderr). This example redirects to a file:
    Cout.output = new FileOutput ("redirected"); = new FileOutput ("redirected");
  • Q: How can I make the program wait for a press of the enter key?
  • A: Use the code below that will read the next line from Cin. Thus pressing just enter is an empty line. If you want to check (or poll) for a key hit, use the C functions like getchar() or getc() from tango.stdc.stdio.

D 2.0

  • Q: Does Tango support D 2.0 as represented by the DMD 2.0xx range of releases?
  • A: No, not officially. A branch exists in Tango's SVN repository with an early attempt, but D 2.0 is still considered too immature and unstable for any full and official commitment to this end. Feel free to contact us if you want to update the branch, though.
  • A: There is also a fork that has about 40% of the work completed at git://

Generic IO

  • Q: I see this conduit thing. What is that?
  • A: The IO package is stream oriented (InputStream & OutputStream), and a conduit is something that plays host to a related pair of these streams. A conduit is a representation of a device such as a file, socket, or console. Most of the conduits in Tango can be found in

Text Formatting

  • Q: How can I format text without printing it to the console?
  • A: Either use tango.text.convert.Format or tango.text.convert.Layout, where the former holds an instance of Layout that is defaulted to char. You might leverage Stdout.layout if already using Stdout, or use the TextFileStream wrapper when writing to a file. All of these use an instance of Layout. Instantiate and use Layout directly if you need to format text using one of the other string types, such as wchar[] or dchar[].


  • Q: I get link errors, even for the simplest hello world applications. What is the problem?
  • A: The usual reason for this is that the library containing the tango.* object files, isn't linked in. Due to the various ways you can build your application (using the compiler directly, a tool like DSSS or other ways), these are not in the same library as the D runtime (libgphobos / libtango-base-dmd.a / tango-base-dmd.lib). Read how to install Tango for further information.

Installing on Macintosh

  • Q: How do I get a working gdc on macintosh?


  • Q: Which debuggers work with D and Tango?
  • A: Ddbg (Windows), Zerobugs (Linux) or GDB should all work to some degree. MSVC6 works fairly effectively too.
  • Q: The debuggee is interrupted by the signal SIGUSR1, how can I avoid that?
  • A: In GDB you can, before running the program, make sure SIGUSR1 and SIGUSR2 are ignored by doing
    handle SIGUSR1 nostop noprint
    handle SIGUSR2 nostop noprint
  • Q: My application tends to crash or deadlock - the stack trace seems to suggest that this happens in the garbage collector. Could my use of SIGUSR1 and SIGUSR2 have something to do with this?
  • A: Definately, yes. On posix systems the GC relies on SIGUSR1 and SIGUSR2 to control the threads during collection - any use of those outside of the GC, either signalling or blocking, is likely to cause crashes and/or deadlocks. Do not use! See also the previous question.


  • Q: There appears to be a lot of classes in Tango. Is it an OOP library?
  • A: Tango is a modular library with a slant towards encapsulation. The tendency is to leverage struct or class to represent something where that makes sense. Having said that, there are large percentage of modules housing so-called free-functions and IFTI templated functions. This is especially evident in the core and text-conversion packages where IFTI is used heavily to support char/wchar/dchar variations. Where the end result is simpler, templated encapsulation has been leveraged instead of IFTI. As a result, certain related functions are sometimes encapsulated in Tango, where they may not be in other libraries. In a nutshell, Tango employs all the tools provided by the language.
  • Q: Why is FilePath an aggregate, instead of free functions?
  • A: Under the covers, file-system functions typically interact with the O/S using a C API. Much of that API operates with a null-terminated string, requiring a conversion from D to C text. A free-function design is somewhat encouraged to invoke heap activity when interfacing with these API, by appending a null on each invocation. FilePath uses encapsulation to avoid this overhead by acting as a specialized text-editor, and employing a little bit of buffering. The heap activity is visible when using FilePath, rather than being hidden under the covers, and it is generally limited to O(1) rather than the O(n) of a per-invocation model. A similar situation exists where editing or concatenation of file-path components takes place.
  • Q: How do I avoid creating a FilePath to see if a file exists?
  • A: Tango provides free-functions in for pedestrian interaction with the file system. Another alternative is to use a scope FilePath instance, or reuse an existing one.
  • Q: Using classes is slower than structs, right?
  • A: Heap activity will reduce the efficiency of any program. This is partly why D supports placing classes on the stack, via the scope keyword. However, the heap can be abused in many (often subtle) ways, so it would be grossly over-simplified to point a finger at the use of class alone. Tango is designed with an explicit goal of limiting the amount of hidden heap activity - if you find a case where that does not hold true, please tell us about it.


  • Q: With Tango I sometimes have to import more modules than with phobos. What's the deal?
  • A: Tango is deliberately modular in order to aid portability, minimize functional coupling, and avoid bloat. A Tango philosophy is to design with modularity in mind, and provide a wrapper layer on top where that makes sense. For example, the tango.util.Convert module provides generic wrappers around discrete text converters. In a similar fashion, much of the package is comprised of wrappers around the more modular portions of the IO system.

Phobos API

  • Q: What's the easiest way to use phobos and Tango together?
  • A: Use the Tangobos extension, which provides the phobos API within the Tango environment. It can be downloaded as a part of a bundle, and there's more information on it over here.

GDC & Tango

  • Q: When running with GDC 0.24 installed, I get chmod: cannot access `../tango/core/*.di': No such file or directory . What is going on?
  • A: This is actually a bug in that version of GDC, in the gdmd frontend script. The problem and a patch is fully described here. The problem is that $header = 1; must be added to the cases for the other to -H options too. GDC 0.24 is no longer supported though.

IDE's and Tango

  • Q: How can I configure my IDE for use with Tango?
  • A: That depends on the make of it, and many may not support D properly at all. You should check out the tool configuration section of this page though - it may just talk about your favourite IDE.

Other Resources

User Comments