d

Efficient Independent Synchronized Blocks?

I have a scenario where, at certain points in my program, a thread needs to update several shared data structures. Each data structure can be safely updated in parallel with any other data structure, but each data structure can only be updated by one thread at a time. The simple, naive way I've expressed this in my code is: synchroniz...

gtkD: Minimal Drawing Example?

I'm a fairly experienced programmer, but new to GUI programming. I'm trying to port a plotting library I wrote for DFL to gtkD, and I can't get drawings to show up. The following code produces a blank window for me. Can someone please tell me what's wrong with it, and/or post minimal example code for getting a few lines onto a Drawing...

GTK: How to ignore "can't open display" errors?

I have written some GTK programs using the gtkD bindings for the D programming language that are otherwise console apps, but are capable of displaying plots on the screen and saving them to a file. I'd like to run these on a machine that I only have console-based SSH access to, which means that the plots wouldn't be displayed on the scr...

Protected module members

According to D docs (http://www.digitalmars.com/d/2.0/attribute.html#ProtectionAttribute) protected module members are illegal, but compiler allow me to do this. module foo; protected { int bar; } Is this error in docs, compiler bug or I am doing something wrong ? Actually this is not the only inconsistency between documentation ...

Is using D string mixins for code reuse an anti-pattern?

For those of you who are not familiar with D string mixins, they're basically compile-time evals. You can take any compile time string (whether a literal or generated by template metaprogramming or compile time function evaluation) and compile it as code. If you use a simple string literal, it's basically compiler-automated copy-paste....

Public Domain or No Binary Attribution FFT Lib?

I'm looking for an FFT library to translate into the D programming language for inclusion either in a library that I'm working on or (better yet) in the standard library. I need a fairly simple FFT with decent performance, not an uber-optimized one with blazing fast performance and zero simplicity/readability. However, it must meet the...

Is it possible to modify the cindent rules for one case in vim?

I am currently using vim as my editor for programming in D. The indent rules are pretty much identical to C, but I've run into a case that vim doesn't handle by default. In D, case statements can take strings which are not properly handled by cindent. For instance, this works: switch(blah) { case 1: // something case some_variabl...

Testing function signatures with ParameterTypeTuple

I'm writing a module with mixin templates to supply a main function for unit-testing purposes. Usage is as follows: /* For modules without their own main, e.g. libraries. * main is conditionally supplied using version(unittest). */ mixin Main; /* For executable modules defining function "realMain". * Generated main has the same sig...

How to read a char[] object into a tango.io.compress.ZlibStream?

I have a D program with Tango and I'm trying to uncompress a gzipped string. unfortunately I don't have A stream to it, but the compressed data is stored in a char[]. how can I uncompress it using tangos tango.io.compress.ZlibStream? I need another char[] with the uncompressed data. I've been trying this for hours now. I'm not very fami...

Associative array .remove[] calling core.stdc.stdio.remove in dmd 2.0

I have the following code in D import std.stdio; class Thing { // Fields private string Name; // Accessors public string name() { return Name; } } class Place: Thing { // Fields private Place[string] Attached; // Modifiers public void attach(Place place) { Attached[place.name()] = place; } public void detach(Place pl...

Is it bad practice to alter dynamic arrays that have references to them?

I looked a bit at dynamic arrays in D2, and I found them very difficult to understand. It also seems I'm interpreting the spec wrongly.. Working on a reference or slice of a dynamic array seems very error prone when changing the arrays... Or am I just not understanding the fundamentals? Referring to the same array only shares the actual...

ranges from associative arrays in D 2

I've just started implementing my first medium scale program in D 2.0 after reading Andrei's book The D Programming Language. One of the first problems I came to was using the std.algorithm library with a built-in associative array. For example: #!/usr/bin/env rdmd import std.stdio; import std.algorithm; void main() { alias int[s...

Distributed message passing in D?

I really like the message passing primitives that D implements. I have only seen examples of message passing within a program though. Is there support for distributing the messages over e.g. a network? ...

D/Phobos Style guide

I've just begun looking at the phobos source, and it's littered with several different styles and commented out code. The style guide on the web side is very small, and I only found broken links from 2006 and another one from 2004... Is there a newer, more comprehensive guide available? PS: Originally asked at the D.learn newsgroup, ...

In D, what's the difference between a private import and a normal import?

In the D programming language, what is the difference between private import tango.io.File; and import tango.io.File; ? ...

Walter Bright's use of the word "redundancy"... or 'The heck does that mean?'

So I'm reading this interview with Walter Bright about the D language in Bitwise (http://www.bitwisemag.com/copy/programming/d/interview/d_programming_language.html), and I come across this really interesting quote about language parsing: From a theoretical perspective, however, being able to generate a good diagnostic requires that ...

File I/O in D programming language

I'm trying to follow a simple tutorial and can't get the following code to work: void main(string args[]) { auto f = File("test.txt", "w"); f.writeln("Hello, Worlds!"); } I'm using the dmd compiler on windows. ...

Specialize a template parameter to implement 2 interfaces in D?

interface I1 { ... } interface I2 { ... } struct List(T) { ... } How do I specialize my List to operate only on classes that implement both I1 and I2? One interface is easy: struct List(T : I1) Other languages. In C# it's: struct List<T> where T : I1, I2 And in Java I'd say: class List<T extends I1 & I2> One catch: I don't wan...

Mixing C and D code in the same program?

Is it possible? i.e. compile .c with dmc and .d with dmd and then link them together, will this work? Will I be able to call D functions from C code, share globals etc? Thanks. ...

D versus Go comparison

It would be interesting to contrast these two new languages by several aspects: What are their design influences? Where do they intersect in their goals / where do they rival? Where are they distinct? For which tasks is one or the other better suited? What is your outlook on these languages? That is, which niche will D resp. Go fill? ...