d

Is D's grammar really context-free?

微笑、不失礼 提交于 2019-12-02 14:21:38
I've posted this on the D newsgroup some months ago, but for some reason, the answer never really convinced me, so I thought I'd ask it here. The grammar of D is apparently context-free . The grammar of C++, however, isn't (even without macros). ( Please read this carefully! ) Now granted, I know nothing (officially) about compilers, lexers, and parsers. All I know is from what I've learned on the web. And here is what (I believe) I have understood regarding context, in not-so-technical lingo: The grammar of a language is context-free if and only if you can always understand the meaning

D Programming Language in the real world? [closed]

和自甴很熟 提交于 2019-12-02 13:54:06
Is anyone out there using D for real world applications? If so, what are you using it for? I can't seem to find anything big on the web written in D. Despite the lack of known big users, D seems like a very promissing language to me, and according to TIOBE , it's fairly popular. I'm using D for my research work in the area of computer graphics. I and others have had papers published in our fields based on work done using D. I think it's definitely ready for use on small to medium sized research projects where performance matters. It's a nice fit for research work because often you're starting

OpenGL Segfaults on glGenVertexArrays

别说谁变了你拦得住时间么 提交于 2019-12-02 09:20:32
问题 OpenGL or SDL segfaults when it reaches the very first statement in the class. I have no idea what is causing it. class RenderEngine { GLuint vertexArrayId; GLfloat[] vertexBufferData = [ -1.0f, -1.0f, 0.0f, 1.0f, -1.0f, 0.0f, 0.0f, 1.0f, 0.0f ]; GLuint vertexBufferId; public this() { glGenVertexArrays(1, &vertexArrayId); // SEGMENTATION FAULT / RETURN -11 glBindVertexArray(vertexArrayId); glGenBuffers(1, &vertexBufferId); glBindBuffer(GL_ARRAY_BUFFER, vertexBufferId); glBufferData(GL_ARRAY

D lang - Using read and readln() in the same program

我是研究僧i 提交于 2019-12-02 06:17:44
问题 I'm having a very strange issue with a D program. read(" %s", variable) works fine by itself and readln(variable) works fine by itself, but when I put the two together, readln() appears to be passed over. The error occurred using both gdc and dmd. import std.stdio; import std.string; void main() { int x; write("Enter a number: "); readf(" %s", &x); write("What is your name? "); string name=chomp(readln()); writeln("Hello ", name, "!"); } Output: Enter a number: 5 What is your name? Hello !

Is there a Future/Promise equivalent of C++ in D?

时光怂恿深爱的人放手 提交于 2019-12-02 05:11:40
Does there exist a future/promise equivalent from the C++ world in the D world? Sure there is std.parallelism but it's doesn't have exactly the functionality of the promise/future combination (there is no equivalent to get the future or the set the result or the exception, you can't also wait for completion). I believe you did not seriously look at std.parallelism ... Equivalent to "get the future" (if by that you mean the std::future 's get() method) are yieldForce(), spinForce() and workForce(). Read about these more carefully and you will see that you can wait for completion as well... std:

D lang - Using read and readln() in the same program

為{幸葍}努か 提交于 2019-12-02 02:10:07
I'm having a very strange issue with a D program. read(" %s", variable) works fine by itself and readln(variable) works fine by itself, but when I put the two together, readln() appears to be passed over. The error occurred using both gdc and dmd. import std.stdio; import std.string; void main() { int x; write("Enter a number: "); readf(" %s", &x); write("What is your name? "); string name=chomp(readln()); writeln("Hello ", name, "!"); } Output: Enter a number: 5 What is your name? Hello ! However, if I comment out readf(" %s", &x), readln is called as I desire: Enter a number: What is your

std.algorithm.joiner(string[],string) - why result elements are dchar and not char?

好久不见. 提交于 2019-12-01 16:43:32
问题 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 ends with error: test.d(8): Error: cannot implicitly convert expression (joiner(x,space).front()) of type dchar to char Changing char z to dchar z does fix the error message, but I'm interested why it appears in the first place. Why result of joiner(string[]

Choosing Between GDC and DMD

时光总嘲笑我的痴心妄想 提交于 2019-12-01 15:41:30
I'm new to programming in D. What are the pros and cons of choosing either DMD (2.061) or GDC (4.6, 4.7 or 4.8, snapshot). And what GDC version should I pick? I've successfully built a recent snapshot of GCC-4.8 and GDC-4.8 and it compiles a hello world program. Here are my thoughts on pros so far: GDC : More platforms, run-time performance DMD : compilation-performance, more tested? What about debugging support through GDB - does it differ between GDC and DMD? Michal Minich Use DMD as it is the reference implementation and is most widely used. It is also the most up to date as new features

Usage preference between a struct and a class in D language

别来无恙 提交于 2019-12-01 14:56:09
When should I define a type as a struct or as a class? I know that struct are value types while classes are reference types. So I wonder, for example, should I define a stack as a struct or a class? Reason #1 to choose struct vs class: classes have inheritance, structs do not. If you need polymorphism, you must use classes. Reason #2: structs are normally value types (though you can make them reference types if you work at it). Classes are always reference types. So, if you want a value type, choose a struct. If you want a reference type, it's easiest to go with a class. Reason #3: If you have

Choosing Between GDC and DMD

℡╲_俬逩灬. 提交于 2019-12-01 14:33:14
问题 I'm new to programming in D. What are the pros and cons of choosing either DMD (2.061) or GDC (4.6, 4.7 or 4.8, snapshot). And what GDC version should I pick? I've successfully built a recent snapshot of GCC-4.8 and GDC-4.8 and it compiles a hello world program. Here are my thoughts on pros so far: GDC : More platforms, run-time performance DMD : compilation-performance, more tested? What about debugging support through GDB - does it differ between GDC and DMD? 回答1: Use DMD as it is the