d

How fast is D compared to C++?

徘徊边缘 提交于 2019-12-29 10:07:09
问题 I like some features of D, but would be interested if they come with a runtime penalty? To compare, I implemented a simple program that computes scalar products of many short vectors both in C++ and in D. The result is surprising: D: 18.9 s [see below for final runtime] C++: 3.8 s Is C++ really almost five times as fast or did I make a mistake in the D program? I compiled C++ with g++ -O3 (gcc-snapshot 2011-02-19) and D with dmd -O (dmd 2.052) on a moderate recent linux desktop. The results

About the non-nullable types debate

允我心安 提交于 2019-12-29 08:35:39
问题 I keep hearing people talk about how non-nullable reference types would solve so many bugs and make programming so much easier. Even the creator of null calls it his billion dollar mistake, and Spec# has introduced non-nullable types to combat this problem. EDIT: Ignore my comment about Spec#. I misunderstood how it works. EDIT 2: I must be talking to the wrong people, I was really hoping for somebody to argue with :-) So I would guess, being in the minority, that I'm wrong, but I can't

dlang call to function in other file fails

穿精又带淫゛_ 提交于 2019-12-25 07:47:18
问题 I'm testing to make calls to functions in other files using D code My problem is that I receive errors I don't understand in server.d import std.stdio; extern (D) void otherFunction(); main(){ otherFunction();} and in client.d import std.stdio; void otherFunction(){ writeln("hello world");} "dmd server.d" renders this output error Undefined symbols for architecture x86_64: "_D6server13otherFunctionFZv", referenced from: __Dmain in server.o ld: symbol(s) not found for architecture x86_64 clang

Looking for datatypes of similar precision in multiple programming languages e.g. C/C++, D, Go

烂漫一生 提交于 2019-12-25 04:53:10
问题 I am trying to implement a program with floating point numbers, using two or more programming languages. The program does say 50k iterations to finally bring the error to very small value. To ensure that my results are comparable, I wanted to make sure I use data types of same precision in different languages. Would you please tell if there is correspondence between float/double of C/C++ to that in D and Go. I expect C/C++ and D to be quite close in this regard, but not sure. Thanks a lot.

Gstreamer on iphone, blackberry, android, nokia? How would it perform?

…衆ロ難τιáo~ 提交于 2019-12-24 19:12:35
问题 Gstreamer on IPhone, Android, Blackberry, Nokia. How can we make it using C or D or Vala languages? Or should we just use Java or Lua? 1) Glib porting to IPhone, Android, Blackberry, Nokia is available? For Android, there is a tips http://gstreamer.freedesktop.org/wiki/GstreamerAndroid_InstallInstructions For IPhone, no idea For Nokia, no idea For Blackberry, no idea Wish someone put some answers and feedback on this topic. 回答1: I don't know much about mobile development, but your best bet

SDL window seemingly improperly being marked 'unresponsive' by OS

梦想的初衷 提交于 2019-12-24 18:08:03
问题 I have an SDL2 windowed window accessed via Derelict 3. It is supposed to strobe black and white (not because I hate epileptics), and it does this successfully. However, after a certain period of time, Ubuntu 13.10 marks the window as 'unresponsive', grays it out, and dulls the strobe effect. This is highly irritating and totally kills the effect required by the application for visual stimulation to retrieve SSVEP readings from my EEG headset. How do I get my OS to realize that the window is

gdc error “Error: module file is in file 'file.d' which cannot be read”

妖精的绣舞 提交于 2019-12-24 11:37:52
问题 I have searched and have seen similar errors but nothing specific as to how to fix this error. Using gdc (D compiler) I get this error message on my crunchbang debian linux machine: gdc main.d fasta.d utilities.d utilities.d:3: Error: module file is in file 'file.d' which cannot be read import path[0] = /usr/include/d2/4.6/x86_64-linux-gnu import path[1] = /usr/include/d2/4.6 utilities.d:3: Error: module file is in file 'file.d' which cannot be read import path[0] = /usr/include/d2/4.6/x86_64

Handling key presses in GTK+ (gtkD)

半世苍凉 提交于 2019-12-24 04:48:10
问题 I'm playing around with gtkD (a D binding for GTK+) I have a window object, instance of gtk.MainWindow . I want to handle keypresses on it. How? How do I deal with special keys (e.g. arrow keys, pgup/pgdn etc)? PS I know these kinds of questions can be answered with google and stuff, but I've seen much "simpler" questions on stackoverflow, so I figured asking doesn't hurt. Plus, sometimes, basic things tend to be burried under pages of documentation. 回答1: Here is sample code which may help

Provide @property for const and non-const structures in D

。_饼干妹妹 提交于 2019-12-24 02:51:50
问题 I define a simple struct this way: struct Person{ private string _name; @property ref string name() { return _name; } } The @property annotation is really cool, but I don't know how should I use it properly. The above is quite ok, but I cannot pass a Person to a function requiring in Person for instance: void fun(in Person p) { ... } To avoid copying Person I have to declare the parameter with ref , though I don't modify it. So how to combine the property syntax with const-correctness? edit:

pure function of functions that returns functions in D

浪子不回头ぞ 提交于 2019-12-24 01:23:18
问题 I'm trying to create a pure function that returns the multiplication of two other pure functions: pure Func multiplyFunctions(Func,Real)(scope const Func f1, scope const Func f2) { return (Real a) { return f1(a) * f2(a); }; } Unfortunately, I'm running into problems, number one, I want to declare f1 and f2 to be pure functions/delegates/classes with opCall defined... which is required because I'm calling them from a pure function. But number two, and what seems to be the most problematic, is