Phobos is the official runtime and standard library of the D programming language.
Questions tagged [phobos]
97 questions
45
votes
6 answers
Does the D language have multiple standard libraries and issues with GC?
I'm wondering how mature and stable D is, and if it might be a good replacement for C/C++.
I know that there are currently two standard libraries (Phobos and Tango). Is it still the case that there is no unified standard library?
Additionally I…

soc
- 27,983
- 20
- 111
- 215
26
votes
8 answers
Should I use Phobos or Tango?
I've decided to learn D, and I'm wondering which standard library I should use. Should I use Phobos or Tango? What are the pros and cons of each?

Zifre
- 26,504
- 11
- 85
- 105
16
votes
2 answers
Why does Phobos use enum for constants?
Why does Phobos use enum to define constants? For example, in std.math:
enum real E = 2.7182818284590452354L;
Why not use a global immutable? What are the advantages/disadvantages of enum over immutable?

Peter Alexander
- 53,344
- 14
- 119
- 168
15
votes
1 answer
D naming conventions: How is Phobos organized?
I'm making my own little library of handy functions and I'm trying to follow Phobos's naming convention but I'm getting really confused. How do I know where things would fit?
Example:
If there was a function like foldRight in Phobos (basically…

user541686
- 205,094
- 128
- 528
- 886
14
votes
3 answers
integer to string conversion in D
How in D would I cast integer to string?
Something like
int i = 15
string message = "Value of 'i' is " ~ toString(i); // cast(string) i - also does not work
Google brought me the answer on how to do it with tango, but I want the phobos version.

dnsmkl
- 792
- 5
- 17
12
votes
2 answers
Effective D : best practices and design patterns
A really interesting conference was given about D-Specific Design Patterns and in the D community, some people thought it could be a starting point for a book dealing about effective coding techniques. Others argue that it was too early as not many…

matovitch
- 1,264
- 11
- 26
11
votes
1 answer
Binary Search in D 2.0 (Phobos)?
Is it just me, or is there no binary search function in Phobos? I have a pre-sorted array that I want to search with my own comparator function, but I can't find anything in std.algorithms or std.containers.
Thanks!

user541686
- 205,094
- 128
- 528
- 886
9
votes
4 answers
What is the current status of D standard libraries?
There are two of them Phobos and Tango.
As far as I know they are redundant and incompatible.
Are there any plans to join them?
If so, when will it happen?

Łukasz Lew
- 48,526
- 41
- 139
- 208
8
votes
2 answers
How to get single keystroke in D2 (Phobos)?
Is there a simple, cross-platform way to get a single keystroke in D2 using Phobos?
For instance, a "Press any key to continue..." prompt, or a Brainfuck interpreter.
All the methods I've tried require an Enter keypress before passing the input…

bfops
- 5,348
- 5
- 36
- 48
8
votes
2 answers
Read Text File in D
Is there any one-size-fits-all (more or less) way to read a text file in D?
The requirement is that the function would auto-detect the encoding and give me the entire data of the file in a consistent format, like a string or a dstring. It should…

user541686
- 205,094
- 128
- 528
- 886
8
votes
1 answer
equivalent of remove_if in D
Recently I have taken an interest in the D programming language. I just started learning it, and am coming from a C++ background. I am wondering if there is an equivalent of std::remove_if. I only saw remove looking through docs on the dlang…

mio iwakura
- 301
- 2
- 11
7
votes
1 answer
Shortest way to concatenate strings in D outside writefln()?
I repeadetly need to concatenate of format strings, and is wondering what is the shortest (or easiest to read) way to concatenate strings outside of the writefln() function, in D?
That is, I like the behaviour of writefln, where you can do for…

Samuel Lampa
- 4,336
- 5
- 42
- 63
7
votes
1 answer
std.algorithm.joiner(string[],string) - why result elements are dchar and not char?
I try to compile following code:
import std.algorithm;
void main()
{
string[] x = ["ab", "cd", "ef"]; // 'string' is same as 'immutable(char)[]'
string space = " ";
char z = joiner( x, space ).front(); // error
}
Compilation with dmd…

dnsmkl
- 792
- 5
- 17
7
votes
4 answers
How do you use ranges in D?
Whenever I try to use ranges in D, I fail miserably.
What is the proper way to use ranges in D? (See inline comments for my confusion.)
void print(R)(/* ref? auto ref? neither? */ R r)
{
foreach (x; r)
{
writeln(x);
}
//…

user541686
- 205,094
- 128
- 528
- 886
7
votes
3 answers
Is D backwards compatible with C if you use the C libraries?
If I import the std.c libaries instead of including the libraries in C, would C code compile with a D compiler, or are there other backwords compatibility issues?

Orcris
- 3,135
- 6
- 24
- 24