D file I/O functions
I'm just learning D. Looks like a great language, but I can't find any info about the file I/O functions. I may be being dim (I'm good at that!), so could somebody point me in the right direction, please? Thanks ...
I'm just learning D. Looks like a great language, but I can't find any info about the file I/O functions. I may be being dim (I'm good at that!), so could somebody point me in the right direction, please? Thanks ...
Is it possible to make one program, written in Java, C++ and D? ...
When a program accesses files, uses system(), etc., how and where is the current working directory of that program physically known/stored? Since logically the working directory of a program is similar to a global variable, it should ideally be thread-local, especially in languages like D where "global" variables are thread-local by def...
Is there a way to dynamically load and call functions from DLLs dynamically in D? I'd like my program to be able to load plugins at startup and perhaps on-the-fly as well. ...
Let's say I have a class like so: class Gerbil{ int id; float x,y,z; } Let's further say this is part of a real-time simulation where I have a server/client setup and I change a property on the server-side: //... gerbil.x = 9.0; //... Now I want to send over this change to the client to synchronize the world state. However,...
Where can I find good solid D documentation? I've been trying to learn D, and am having issues finding good reference docs for the language. For instance, I see op opImplicitCast talked about back in 2007...was that ever implemented? Overall the language information seems to be extremely fragmented between dsource the digitalmars site...
I have: Foo foo = new Foo(); foreach (i; 0..10) { Bar bar = foo.getBar(i); ... } I want to be able to instead say (equivalently): foreach (bar; foo.getAllBars()) { ... } How do I go about implementing getAllBars()? I figured something like this: class Foo { auto getAllBars() { return map!(getBar)(iota(10)); } } ...
Here is a simple generator in C#. IEnumerable<int> Foo() { int a = 1, b = 1; while(true) { yield return b; int temp = a + b; a = b; b = temp; } } How do I write a similar generator in Digital Mars D? (The question is about the yield return sta...
Coming from a C/C++ background. What is the proper way to link a D static (or dynamic) library to a D .exe file? Can I simply "import" the module from the library and then link to the .lib file at compile time? ...
How to read and write to binary files in D language? In C would be: FILE *fp = fopen("/home/peu/Desktop/bla.bin", "wb"); char x[4] = "RIFF"; fwrite(x, sizeof(char), 4, fp); I found rawWrite at D docs, but I don't know the usage, nor if does what I think. fread is from C: T[] rawRead(T)(T[] buffer); If the f...
Will be nice if I got 'nested members' in D language, so I have the inglorious idea to code class Keyboard { struct Unused { string key1 = "Wake Up"; string key2 = "Sleep"; string key3 = "Power"; } Unused unused; } int main() { Keyboard kb; kb.unused.key1 = "Scroll Lock"; return 0; } ...
I like haskell and many things connected with it as its type-engine, lot of packages at Hackage, nice community, active development etc. Otoh, I had experience that some people gave up on our planned project considering Haskell too complicated (monads, lot of jargon from academia...) to grok (coming from C++ background), so it might be ...
Here is an example: int[] arr = [ 1, 2, 3, 4, 5 ]; auto foo = filter!("a < 3")(arr); assert(foo == [ 1, 2 ]); // works fine Now I want to be able to parameterize the predicate, e.g. int max = 3; int[] arr = [ 1, 2, 3, 4, 5 ]; auto foo = filter!("a < max")(arr); // doesn't compile This snippet won't compile obviously, sine the filte...
I have a class that I'm implementing ranges for. I'd like to implement the functions the way the phobos library does, i.e. outside the main class. void popBack(T)(ref T[] a) if (!is(Unqual!T == char) && !is(Unqual!T == wchar)) { assert(a.length); a = a[0 .. $ - 1]; } Here's my version: void popFront(T)(ref PersistentList!(T)...
Don't know if is possible, I want receive maybe data[n] or data[n][n][n]. In C could be (correct me if wrong): void save_data(void* arr, int n, int dimensions) { // do ugly things } But must exist a more elegant way in D. ...
Say I have to deal ushort and uint some way, but string differently. So guess I need one specialized template for string and other to both ushort and uint. Is it? // for most void func(T)(T var) { ... } // for uint and ushort void func(T: uint, ushort)(T var) { ... } That is the idea, although the code can't compile. It's valid or ...
In D main fnc is defined: void main(/*perhaps some args but I do not remember*/) { } My question is that I know for sure that this fnc returns zero on success and non-zero on failure and yet it is defined as to not returning anything. What is the logic behind it? ...
I want the following struct as a class member, but I don't know the type of T, so I need "declare" the struct at runtime. struct Chunk (T) { string id; T[][] data; } class FileBla { this() { Chunk !int ck; // need to be turned in a class member } } Should be missing something easy. ...
Hello! We are looking for adequate build tool for a desktop GUI application to be written in D (using Qt toolkit), consisting of several native libraries, using 3rd party C-lib(s). It has to build on Linux (native development) and Mac as well on Windows. We might adopt Code::Blocks as IDE. Waf already has support for D language, while ...
I've been playing around with D for a few days and was getting quite excited about it until, that is, I tried to get gtkd working. I've now wasted the best part of 3 days trying to get a working setup and am beginning to get (read; long ago got) a bit demoralised. I was wondering if anyone can help before I give up. A lot of the informat...