d

Checking in D if a string is in array?

How do I check for a string occurance in an array? I mean sure I can loop, but is there a standard function? at first I did: if(str in ["first", "second", "third"]) but it complained that in only works with associative arrays. I tried to quickly lookup the phobos docs but didn't find any module related to arrays. So is there anythi...

vim: associate extension with language

I have gvim 7.2, it recognizes .d files and highlights it correctly according to the syntax of the D programming language. However, .di files are not recognized as D files, and no highlighting is present. How do I let vim highlight .di files according to D language? ...

In D, how to pass an empty string? (to gtkD)

Using D1 with phobos I have a text entry field, instance of gtk.Entry.Entry, calling setText("") raises a run time error Gtk-CRITICAL **: gtk_entry_set_text: assertion `text != NULL' failed Why? It seems to be a problem with D, I tried this: string empty = ""; assert (empty != null); my_entry.setText(empty) The program terminated...

What debugger can be used with D 2.0 on windows and how do I use it?

I have been playing around with D 2.0 a bit today mostly because of the "The Case for D" in DDJ. I have downloaded D 2.0 for windows but have not figured out how to step through a running program in the debugger. I tried to get the shipped copy of windbg.exe to work but it is crashing on me all the time and does not seem to see the sou...

How to use pure in D 2.0

While playing around with D 2.0 I found the following problem: Example 1: pure string[] run1() { string[] msg; msg ~= "Test"; msg ~= "this."; return msg; } This compiles and works as expected. When I try to wrap the string array in a class I find I can not get this to work: class TestPure { string[] msg; void ad...

memory paging with D

I'm using D/Tango for catalog indexing, is there any library to aid with memory (RAM) paging for a dictionary which is in memory and can go up to 10gb while performing indexing? ...

Do getters and setters impact performance in C++/D/Java?

This is a rather old topic: Are setters and getters good or evil? My question here is: do compilers in C++ / D / Java inline the getters and setter? To which extent do the getters/setters impact performance (function call, stack frame) compared to a direct field access. Besides all the other reasons for using them, I would like to know...

Make GDC front end emit intermediate C/C++ code?

While investigating the D language, I came across GDC, a D Compiler for GCC. I downloaded the version for MinGW from here: http://sourceforge.net/projects/dgcc/files/ Documentation was almost nonexistent, but it did say that most of the command line switches were the same as for the GCC compiler. However, that doesn't help me much, s...

Serialisation and Databasetechnics to locate objects

Hello there, I was wondering if there is a (c++ or D) serialisation library that also provides technics to locate a certain object (which was saved to disk) based to certain criterias like a certain attribute combination. I know about sqlite and mySQL and so own, but I search for an alternative. Because those databases are not bound to...

How would you approach using D in a embedded real-time environment?

To all those familiar with D programming language, how would go about using it in a embedded real-time environment? I understand that it's original design is not targeted for real-time embedded environments, but this question is more about how would you go about making real-time capability happen. Which constructs of the language would ...

What are the limitations of primitive character types in D?

I am currently exploring the specification of the Digital Mars D language, and am having a little trouble understanding the complete nature of the primitive character types. The book Learn to Tango With D is similarly vague on the capabilities and limitations of the language in this area. The types are given on the website as: char; ...

Demos, samples and proof-of-concept code in D

I've been looking at the D programming language recently and I'm curious if there are any demos, sample applications, or proof-of-concept code written in it. I want some code that demonstrates situations where D is particularly elegant or advantageous. There's dsource.org of course, but the projects hosted there are full-on applications...

Can I create a Python extension module in D (instead of C)

I hear D is link-compatible with C. I'd like to use D to create an extension module for Python. Am I overlooking some reason why it's never going to work? ...

Getting Embedded with D (the programming language)

I like a lot of what I've read about D. Unified Documentation (That would make my job a lot easier.) Testing capability built in to the language. Debug code support in the language. Forward Declarations. (I always thought it was stupid to declare the same function twice.) Built in features to replace the Preprocessor. Modules Typedef ...

Is D's scope failure/success/exit necessary?

When using a language that has try/catch/finally is D's failure/success/exit scope statements still useful? D doesnt seem to have finally which may explain why those statements are using in D. But with a language like C# is it useful? I am designing a language so if i see many pros i'll add it in. ...

Sorting based on associative arrays in D

Hi I am trying to follow examples given in various places for D apps. Generally when learning a language I start on example apps and change them myself, purely to test stuff out. One app that caught my eye was to count the frequency of words in a block of text passed in. As the dictionary was built up in an associative array (with the ...

malloc and free in D/Tango not freeing memory?

here is a simple d/tango code in windows: module d_test.d; import tango.util.log.Trace; import tango.core.Thread; import tango.stdc.stdlib : malloc, free; void main() { Trace.formatln("Checking in..."); Thread.sleep(10); int total_n = (100 * 1000 * 1000) / int.sizeof; // fill mem with 100MB of ints int* armageddon = ...

Can you refer to a named enum as if it were anonymous in D?

I'm doing a D bridge to a C library, and this has come up with the C code using typedef'd enums that it refers to like a constant, but can name it for function arguments and the like. Example: enum someLongNameThatTheCLibraryUses { A, B, } Currently, I must refer to it like so: someLongNameThatTheCLibraryUses.A; But I wou...

How should I handle C-strings in D?

I'm converting the header files of a C library to D modules, and was wondering how I should handle C strings. Using DMD 1, this works: void f(char* s); // Definition for C library's function. But using DMD 2 (which I personally use, but I would like the modules to work for both) strings are const, so to get the same code using the m...

How do I initialise a global array of structs in D?

In aid of my one-man quest to populate SO with D questions (=p), I've run into another problem; initialising an array of structs globally. Observe: struct A { int a; float b; } A[2] as; as[0] = {0, 0.0f}; as[1] = {5, 5.2f}; void main() {} Results in: $ dmd wtf.d wtf.d(8): no identifier for declarator as[0] wtf.d(9): no ide...