Re: Unable To Install Debian Package on Deepin Linux (Debian Jessie)
On Wednesday, 16 November 2016 at 02:24:26 UTC, azzuwan wrote: It seems that /usr/bin/dman is currently used by deepin-manual. Is there anyway to get around this? Take a look at dpkg-divert(1)
[Vibe.d] Handling event loop manually
In my application I have already have an event loop running taking care of all sorts of things. Now I want to use Vibe.d to run an asynchronous websocket API to provide some debugging information. Normally Vibe.d's main takes care of handling the event loop. I want to run vibe's event loop manually. So far I tried to get the EventDriver and calling processEvents() but this does not seem to service any connections at all. runEventLoop() and runEventLoopOnce() do process the connections but of course block the whole event loop. Does anyone know how I can do this?
Re: How to create a UTF16 text file on Windows?
Dne 16.11.2016 v 23:43 lafoldes via Digitalmars-d-learn napsal(a): Hi, I'd like to create a UTF16 text file on Windows 7, using std.stdio.File and std.stdio.File.write... functions (so no binary write, no Win32 functions). I was experimenting with variations of this code…: import std.stdio; int main(string[] argv) { auto output = File("wide_text.txt", "wt"); output.writeln!wstring("A"w); return 0; } …and didn't succeed; the output was [0x41, 0x0d, 0x0a] and not what I dreamed about: [\ufeff, \u0041, \u000d, 0u000a]. (After I looked into the Phobos source code, well, it was not a surprise...) VS2015 (and its runtime) has a non-standard solution for this; the c++ code below does the trick: #include #include void main() { FILE * output; fopen_s(, "test.txt", "wt+,ccs=UTF-16LE"); fwprintf(output, L"A\n"); fclose(output); } Do you know about anything of similar complexity in D? If not, I think it would be useful. http://dlang.org/phobos/std_stdio.html#.toFile
How to create a UTF16 text file on Windows?
Hi, I'd like to create a UTF16 text file on Windows 7, using std.stdio.File and std.stdio.File.write... functions (so no binary write, no Win32 functions). I was experimenting with variations of this code…: import std.stdio; int main(string[] argv) { auto output = File("wide_text.txt", "wt"); output.writeln!wstring("A"w); return 0; } …and didn't succeed; the output was [0x41, 0x0d, 0x0a] and not what I dreamed about: [\ufeff, \u0041, \u000d, 0u000a]. (After I looked into the Phobos source code, well, it was not a surprise...) VS2015 (and its runtime) has a non-standard solution for this; the c++ code below does the trick: #include #include void main() { FILE * output; fopen_s(, "test.txt", "wt+,ccs=UTF-16LE"); fwprintf(output, L"A\n"); fclose(output); } Do you know about anything of similar complexity in D? If not, I think it would be useful.
Re: Compiling and linking libraries
On Wednesday, 16 November 2016 at 14:59:40 UTC, Edwin van Leeuwen wrote: If you are happy to use dub I would just add the GL library as a dependency to my dub.json file. Then if you call dub it will download and compile the necessary file. Example dub.json file: ``` { "name": "myWindow", "authors": [ "Darren" ], "description": "A minimal D application.", "copyright": "Copyright © 2016, Darren", "dependencies": { "derelict-gl3": "~>2.0.0-alpha.2" } } ``` You'll also want the derelict-glfw3 binding so that you can create the window and OpenGL context in the same way as the learnopengl.com tutorials. Moreover, as the maintainer of Derelict, I advise against using the 'alpha' versions of the Derelict libraries for now given that this is a learning exercise. Your dependencies should look more like this: "dependencies": { "derelict-gl3": "~>1.0.19" "derelict-glfw3" : "~>3.1.1" } You don't need to worry about CMake, as DUB fills that role (and more). You also don't need to worry about GLEW, which is strictly a C and C++ thing. DerelictGL3 will perform the same function. Just make sure you have the latest GLFW DLL in your project directory on Windows, or have installed it in the system directories on Mac or Linux. On Windows, you can save yourself some trouble by structuring your tutorial directories something like this: - learnogl - bin -- glfw3.dll -- HelloWindow --- dub.json -- HelloTriangle --- dub.json Then, somewhere in each dub.json, add the following line: "targetPath": "../bin" Make sure each dub.json has a different "name". On Mac or Linux, the GLFW shared library will be in on of the system directories after you install it, so you don't need to worry about it. Here are some major points you need to be aware of that will differ from the tutorial: * You don't need to link with any libraries. All of the Derelict packages are dynamic bindings by default [1], so there are no link-time dependencies. That means the share libraries (DLLs) need to be loaded manually. Before you call any OpenGL or GLFW functions, you need the following two lines (preferably at the top of your main function to play it safe): DerelictGL3.load(); DerelictGLFW3.load(); This will load the libraries. For GLFW, that's all you need to use it. For OpenGL, this will only load the the functions up to 1.1. In order to load the rest, you first need to create a context. In the learnopengl.com tutorial called 'Hello Window', completely ignore the following: glewExperimental = GL_TRUE; if (glewInit() != GLEW_OK) { std::cout << "Failed to initialize GLEW" << std::endl; return -1; } Remember, you don't need GLEW. Instead, replace it with this: DerelictGL3.reload(); Make sure it's after the call to glfwMakeContextCurrent. With that, you'll be able to mostly use the same C code the tutorial uses in your D programs. There are a small number of subtle differences that will cause the D compiler to complain (mostly about implicit conversions), but I won't list them here because that will just confuse you. When you encounter them, if it isn't obvious what's going on, you can always come back here and ask for help. [1] http://derelictorg.github.io/bindings/
Re: Compiling and linking libraries
On Wednesday, 16 November 2016 at 14:27:41 UTC, Darren wrote: Hey all, This is a very beginner problem, but not one I know how to do on my own. Could anyone give a step-by-step guide on how to compile libraries, and then use them in my project with DUB? If you are happy to use dub I would just add the GL library as a dependency to my dub.json file. Then if you call dub it will download and compile the necessary file. Example dub.json file: ``` { "name": "myWindow", "authors": [ "Darren" ], "description": "A minimal D application.", "copyright": "Copyright © 2016, Darren", "dependencies": { "derelict-gl3": "~>2.0.0-alpha.2" } } ``` This will build the necessary library into your library though, so it is not the same as using a static library. Also see the "Creating an own project" section on https://code.dlang.org/getting_started
Compiling and linking libraries
Hey all, This is a very beginner problem, but not one I know how to do on my own. Could anyone give a step-by-step guide on how to compile libraries, and then use them in my project with DUB? For example, I've been using this guide for graphics: http://www.learnopengl.com/#!Getting-started/Creating-a-window In this, it says to use CMake, configure for an IDE, etc. But I am not sure how to use this with D, and I'm not using an IDE (only a text editor and dub). I've gotten by with just copy-pasting pre-compiled binaries into my project folder, but I should learn how to use static libraries (I hope I'm using the right terminology). Thanks!
Re: an extremely naive question regarding synchronized...
static MySingleton get() { if (instance_ is null) { synchronized { if (instance_ is null) { atomicStore(instance_, new MySingleton); } } } return instance_; } This should work fine and faster.
Re: Correct way to create singleton?
On Thursday, 10 November 2016 at 17:17:51 UTC, Konstantin Kutsevalov wrote: Hi, what is a correct (and simple) way to create an singleton? This is how I see that now: ``` class ApMessageRouter { static ApMessageRouter instance = null; private this() { } // for disable constructor to use from outside public ApMessageRouter getInstance() { if (this.instance is null) { this.instance = new ApMessageRouter(); } return this.instance; } } ``` Thank you. Hi Guys Singleton pattern falls under Creational Pattern of Gang of Four (GOF) Design Patterns in .Net. It is pattern is one of the simplest design patterns. This pattern ensures that a class has only one instance. In this article, I would like share some useful link and helpful link. I hope it will help you to implementing singleton in correct way. https://www.mindstick.com/forum/33927/how-to-implement-singleton-design-pattern-in-c-sharp http://blogs.tedneward.com/patterns/Singleton-CSharp/ Thanks