Re: Setting up dmd properly
On 2016-01-11 01:47:54 +, Jason Jeffory said: and how does one link in compiled static libraries into a dub project? I tried adding stuff like "lflags" : ["+C:\\MyLibs\\"], with the .lib file in it, but that doesn't work. (I'd expect to have to supply the file name somewhere, at least) Thanks. I agree with all your other points. Telling explicit what's going on would help a lot in daily business. Not only for D but all compiler stuff. But it seems to be tradition to not do this. Anyway, regarding the static libs. I used this on a Win64 project and it works: "lflags" : [ "D:\\develop\\cairo\\cairo\\src\\release\\cairo-static.lib", "D:\\develop\\cairo\\libpng\\libpng.lib", "gdi32.lib" ], -- Robert M. Münch http://www.saphirion.com smarter | better | faster
Re: Anyone using glad?
Ok. So I tried it out and having some issues ;/ got it basically to compile but 2 problems: 1. I have to get dub to include the lib, not a big deal, shouldn't be issue if I can get the right lib in. (not sure if I have to do all that conversion just or not, and glfw has several libs for different VS versions and such... not sure what that's all about). 2. I had to commend out the following code dealing with the keyboard callback: // Set the required callback functions //glfwSetKeyCallback(window, _callback); gives the error function app.key_callback (GLFWwindow* window, int key, int scancode, int action, int mode) is not callable using argument types () I tried with and without address passing. I can cast though glfwSetKeyCallback(window, cast(GLFWkeyfun)_callback); works(no errors, at least), and if that's correct, leaves only the lib issue. alternate thing I tried but gladLoadGL undefined //(gladLoadGL()); // optionally you can pass a loader to this function //writefln("OpenGL Version %d.%d loaded", GLVersion.major, GLVersion.minor); import std.stdio; import glad.gl.all; import deimos.glfw.glfw3; // Window dimensions const GLuint WIDTH = 800, HEIGHT = 600; void main() { glfwInit(); // Set all the required options for GLFW glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3); glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); glfwWindowHint(GLFW_RESIZABLE, GL_FALSE); // Create a GLFWwindow object that we can use for GLFW's functions GLFWwindow* window = glfwCreateWindow(WIDTH, HEIGHT, "LearnOpenGL", null, null); glfwMakeContextCurrent(window); if (window == null) { writeln("Failed to create GLFW window"); glfwTerminate(); return; } // Set the required callback functions //glfwSetKeyCallback(window, _callback); //(gladLoadGL()); // optionally you can pass a loader to this function //writefln("OpenGL Version %d.%d loaded", GLVersion.major, GLVersion.minor); /* if (!gladLoadGLLoader(cast(GLADloadproc) glfwGetProcAddress)) { writeln("Failed to initialize OpenGL context"); return; }*/ // Define the viewport dimensions glViewport(0, 0, WIDTH, HEIGHT); // Game loop while (!glfwWindowShouldClose(window)) { // Check if any events have been activated (key pressed, mouse moved etc.) and call corresponding response functions glfwPollEvents(); // Render // Clear the colorbuffer glClearColor(0.2f, 0.3f, 0.3f, 1.0f); glClear(GL_COLOR_BUFFER_BIT); // Swap the screen buffers glfwSwapBuffers(window); } // Terminates GLFW, clearing any resources allocated by GLFW. glfwTerminate(); return; } // Is called whenever a key is pressed/released via GLFW void key_callback(GLFWwindow* window, int key, int scancode, int action, int mode) { writeln(key); if (key == GLFW_KEY_ESCAPE && action == GLFW_PRESS) glfwSetWindowShouldClose(window, GL_TRUE); }
Re: Setting up dmd properly
On Monday, 11 January 2016 at 01:24:44 UTC, Jason Jeffory wrote: On Monday, 11 January 2016 at 01:22:28 UTC, Jason Jeffory wrote: Dmd's setup construction is a bit weird and has some difficult issue tracking. How about if dmd supported, if it already doesn't, some ways to help the user check the configuration of dmd. It would be quick and easy to implement. e.g., dmd -showinfo Target Arch: x86 Libraries: C:\Mylib;C:\Another\Lib\Somewhere Modules: C:\MyModules; Version: 2.062 etc... This way, issues between 64 and 32 paths can easily be seen... figuring out exactly what sc.ini is doing is easier, etc... We know it is accurate because it would come from the compiler itself. No guessing. Probably a dmd app could be created that does this instead? Basically I've ran into issues before setting up D because of path issues(again, the sc.ini file is pretty crappy... littered with duplicate symbols and different paths with "hacks" for different compilers and all that(it's just not sain)). It tends to make me hesitant dealing with dmd in some cases. Something that should take a min to do can take hours trying to track down some weird issue simply because of a typo... and there's no way to know exactly what the compiler is "seeing"... I really hope something like this already exists. Also, any linked in libraries could report there format and such. I've had problems figuring out certain coeff libs issues and all that. Knowing exactly what's going on is a good thing, right?!?!? and how does one link in compiled static libraries into a dub project? I tried adding stuff like "lflags" : ["+C:\\MyLibs\\"], with the .lib file in it, but that doesn't work. (I'd expect to have to supply the file name somewhere, at least) Thanks.
Re: ndslice, using a slice in place of T[] in template parameters
On Monday, 11 January 2016 at 00:50:37 UTC, Ilya Yaroshenko wrote: I will add such function. But it is not safe to do so (Slice can have strides not equal to 1). So it is like a hack ([0, 0, 0])[0 .. ret.elementsCount]). Have you made comparison between my and yours parallel versions? https://github.com/9il/examples/blob/parallel/image_processing/median-filter/source/app.d -- Ilya Thanks. No, I haven't studied it previously, but I see how you used the 'hack' in your code, and it works out to the statement below in my case. medians[i] = median(vec, ([task,0])[0 .. bigd]); which compiled. It ran in the faster time without the .array copying. parallel time medians msec:87 That 'hack' seems to be related to the third from below. https://dlang.org/spec/arrays.html b = a; b = a[]; b = a[0 .. a.length];
Re: cairo(D) / x64 / unresolved externals / don't know why
On Sunday, 10 January 2016 at 22:22:03 UTC, Robert M. Münch wrote: I made to compile a bunch of libs on Win64 and got my D project compiled as well. Only problem left are some strange unresolved externals. Linking... dmd -of.dub\build\application-debug-windows-x86_64-dmd_2069-F0A1450B9B033D5CD11F3F60481557B0\webchat.exe .dub\build\application-debug-windows-x86_64-dmd_2069-F0A1450B9B033D5CD11F3F60481557B0\webchat.obj ..\vibe-d-0.7.26\lib\win-amd64\libeay32.lib ..\vibe-d-0.7.26\lib\win-amd64\ssleay32.lib ..\cairoD\cairoD.lib C:\Users\robby\AppData\Roaming\dub\packages\derelict-ft-1.0.2\lib\DerelictFT.lib C:\Users\robby\AppData\Roaming\dub\packages\derelict-util-2.0.4\lib\DerelictUtil.lib C:\Users\robby\AppData\Roaming\dub\packages\x11-1.0.9\x11.lib ..\vibe-d-0.7.26\vibe-d.lib wsock32.lib ws2_32.lib advapi32.lib user32.lib -LD:\develop\cairo\cairo\src\release\cairo-static.lib -LD:\develop\cairo\libpng\libpng.lib -Lgdi32.lib -m64 -m64 -m64 -m64 -m64 -m64 -g cairo-static.lib(cairo-image-source.obj) : error LNK2001: unresolved external "__imp__hypot" and some more missing in other .obj files: "__imp__ctime64" "__imp_ldiv" "__imp_strncpy" "__imp_rand" IMO this all looks like msvcrt standard lib stuff so wondering why it's not found. Do I explicitly have to link to the msvcrt lib? You should not need to link manually against msvcrt, dmd does this for you. You can view the linker commands that are stored inside a object file via microsoft dumpbin tool "dumpbin /DIRECTIVES your.obj". You should check the declarations of the functions that cause a unresolved external error. If they have a "export" in front of them, remove the export. I can not think of any other reason why dmd would otherwise reference a import symbol. Import symbols are symbols used for dll linking and start with "__imp_" Out of curiosity, why do you pass "-m64" 6 times to dmd? Once would be enough. For debug builds targeting windows 64 I would also highly recommend using "-gc -op" instead of "-g". This will give a much better debugging experience in Visual Studio.
Using libraries for (Postgre)SQL for bilingual (C++ and D) project
Hello! I have a project, which consists of 2 parts: web part (based on vibe.d) and core part (C++/Qt 5.5.x). Core will be used in a shared object (c-style exported functions). Both parts must interact with PostgreSQL. Core dynamic library will be contributor to my database (INSERTS/UPDATES), while vibe.d part will use SELECTs for views. Which C++ and D libraries for SQL queries should be used in order to minimize boilerplate code? I don't mind against ORM, using plain old objects (PODs) with special attributes. BTW, I've read about https://github.com/chrishalebarnes/quill.d.
Re: Using libraries for (Postgre)SQL for bilingual (C++ and D) project
On Monday, 11 January 2016 at 07:29:02 UTC, Eliatto wrote: Hello! I have a project, which consists of 2 parts: web part (based on vibe.d) and core part (C++/Qt 5.5.x). Core will be used in a shared object (c-style exported functions). Both parts must interact with PostgreSQL. Core dynamic library will be contributor to my database (INSERTS/UPDATES), while vibe.d part will use SELECTs for views. Which C++ and D libraries for SQL queries should be used in order to minimize boilerplate code? I don't mind against ORM, using plain old objects (PODs) with special attributes. BTW, I've read about https://github.com/chrishalebarnes/quill.d. DDBC contains PostgreSQL driver. https://code.dlang.org/packages/ddbc API is similar to ODBC/JDBC.
Function accepts const ubyte[], const char[], immutable ubyte[], immutable char[]
Hello. 1st Novice question: i want function, operates sometimes with char[], sometimes with ubyte[]. internally it works with ubyte. i can use overloading: void myFunc(ubyte[] arg) {...}; void myFunc(char[] arg) { ubyte[] arg2 = cast(ubyte[]) arg; ...} It is OK. But i want 2 params (arg1, arg2), so i need write 4 overloading functions. I fill templated needed, can anybody show me the way? And 2nd question: what if additionally to written above, function shuld return ubyte[] or char[] ? can compiler guess what return type need from code? something like: char[] cc = myFunc() ubyte[] bb = myFunc() Thanks.
Re: issue porting C++/glm/openGL to D/gl3n/openGL
On Sunday, 10 January 2016 at 10:35:34 UTC, Johan Engelen wrote: It's pretty strange that there is no "translate" method... Didn't see it in the online docs, but in the source there is the "translate" method that you should use.
Re: issue porting C++/glm/openGL to D/gl3n/openGL
On Sunday, 10 January 2016 at 02:51:57 UTC, WhatMeWorry wrote: I thought just swapping the order would fix things: transform = transform.rotate(0.78539, vec3(0.0f, 0.0f, 1.0f)); transform = transform.translation(vec3(0.5f, -0.5f, 0.0f)); but now the square is moved to the lower right corner but no rotation happened? (Disclaimer: I know absolutely nothing about gl3n.) Note that you wrote "translatION", instead of "translatE". Reading the documentation, "translation" does not apply but instead it sets the matrix to a certain translation. See the difference between "rotate" and "rotation" methods. It's pretty strange that there is no "translate" method...
Re: Function accepts const ubyte[], const char[], immutable ubyte[], immutable char[]
On Sunday, 10 January 2016 at 10:10:46 UTC, zabruk70 wrote: Hello. 1st Novice question: i want function, operates sometimes with char[], sometimes with ubyte[]. internally it works with ubyte. i can use overloading: void myFunc(ubyte[] arg) {...}; void myFunc(char[] arg) { ubyte[] arg2 = cast(ubyte[]) arg; ...} It is OK. But i want 2 params (arg1, arg2), so i need write 4 overloading functions. I fill templated needed, can anybody show me the way? No you actually don't have to write all possible overloads. For example: (surely not the best solution) import std.traits; ubyte[] myFuncImpl(ubyte[] a, ubyte[] b) { return a ~ b; } ubyte[] myFunc(T1,T2)(T1[] a, T2[] b) if(is(Unqual!T1 == ubyte) || is(Unqual!T1 == char) || is(Unqual!T2 == ubyte) || is(Unqual!T2 == char)) { return myFuncImpl(cast(ubyte[]) a, cast(ubyte[]) b); } And 2nd question: what if additionally to written above, function shuld return ubyte[] or char[] ? can compiler guess what return type need from code? No. Your function call signature would be completely the same.. The way to do this is to make the function a template and pass the return parameter to it. So you're able to do something like: auto val = myReturnFunc!int(); togrue
Re: sliced().array compatibility with parallel?
On Sunday, 10 January 2016 at 01:16:43 UTC, Ilya Yaroshenko wrote: On Saturday, 9 January 2016 at 23:20:00 UTC, Jay Norwood wrote: I'm playing around with win32, v2.069.2 dmd and "dip80-ndslice": "~>0.8.8". If I convert the 2D slice with .array(), should that first dimension then be compatible with parallel foreach? [...] Oh... there is no bug. means must be shared =) : shared double[1000] means; I'd say, if `shared` is required, but it compiles without, then it's still a bug.
Re: Bug in csv or byLine ?
On Friday, 8 January 2016 at 13:53:06 UTC, Guillaume Chatelet wrote: On Friday, 8 January 2016 at 13:22:40 UTC, Tobi G. wrote: On Friday, 8 January 2016 at 12:13:59 UTC, Guillaume Chatelet wrote: On Friday, 8 January 2016 at 12:07:05 UTC, Tobi G. wrote: No, sorry. Under Windows DMD v2.069.2 it works perfectly in both cases. Which compiler do you use? - DMD64 D Compiler v2.069.2 on Linux. - LDC 0.16.1 (DMD v2.067.1, LLVM 3.7.0) I ran it now under Linux/Ubuntu DMD64 D Compiler v2.069.2 But both still worked.. Are there some characters in your input data which are invalid and not displayed in the forum? (multiple empty lines after the actual csv data for example) togrue Indeed there's an empty line at the end of the csv. Interestingly enough if I try with DMD64 D Compiler v2.069, the Fail version runs fine but the normal version returns: std.csv.CSVException@/usr/include/dlang/dmd/std/csv.d(1246): Row 3's length 1 does not match previous length of 2. I still do not understand half of the syntax(still learning) but my guess is that it is a bug in the csv reader: In https://github.com/D-Programming-Language/phobos/blob/67c95e6de21d5d627e3c57128b4d6e332c82f785/std/csv.d line 1020 calls popfront on the input without checking that it input is empty. But this only happen in special case if the last line is \r\n if i understand it correctly. I might be totally wrong because it does not match your stackstrace and i did not yet understand everything about this.
Re: sliced().array compatibility with parallel?
On Sun, 2016-01-10 at 01:46 +, Jay Norwood via Digitalmars-d-learn wrote: > […] > // processed non-parallel works ok > foreach( dv; dv2){ > if(dv != dv){ // test for NaN > return 1; > } > } > > // calculated parallel leaves out processing of many values > foreach( dv; dvp){ > if(dv != dv){ // test for NaN > return 1; > } > } > return(0); > } I am not convinced these "Tests for NaN" actually test for NaN. I believe you have to use isNan(dv). -- Russel. = Dr Russel Winder t: +44 20 7585 2200 voip: sip:russel.win...@ekiga.net 41 Buckmaster Roadm: +44 7770 465 077 xmpp: rus...@winder.org.uk London SW11 1EN, UK w: www.russel.org.uk skype: russel_winder signature.asc Description: This is a digitally signed message part
Re: Function accepts const ubyte[], const char[], immutable ubyte[], immutable char[]
On Sunday, 10 January 2016 at 11:13:00 UTC, Tobi G. wrote: ubyte[] myFunc(T1,T2)(T1[] a, T2[] b) Tobi, big thanks!!! I should learn templates...
Re: Dub pre-build hook
On Sun, 10 Jan 2016 16:34:51 +, Chris Wright wrote: > Is there a way to write a pre-build hook in Dub? > > Specifically, I want to write unittests in a separate package to the > rest of my source code. This requires a module that imports all my > unittest modules. It's safer to automatically generate this than to rely > on my memory. > > My other alternative is to write a D script that assembles this file and > then invokes dub, and always invoke dub via that script. I write this and immediately see preBuildCommands and preGenerateCommands. I'm not sure what the difference is, though. I think preBuildCommands is the way to go (and preGenerateCommands is maybe for generating project files). I'll give it a shot and see how it turns out.
Re: issue porting C++/glm/openGL to D/gl3n/openGL
On Sunday, 10 January 2016 at 10:38:07 UTC, Johan Engelen wrote: On Sunday, 10 January 2016 at 10:35:34 UTC, Johan Engelen wrote: It's pretty strange that there is no "translate" method... Didn't see it in the online docs, but in the source there is the "translate" method that you should use. That's it! Excellent catch. Thank you. gll3n has translate(), rotate(), and scale() and matrix operators. It also has translation(), rotation(), and scaling() which /// Returns a translation matrix (3x3 and 4x4 matrices). /// Returns an identity matrix with an applied rotate_axis around an arbitrary axis (nxn matrices, n >= 3). /// Returns a scaling matrix (3x3 and 4x4 matrices);
Re: sliced().array compatibility with parallel?
On Sunday, 10 January 2016 at 11:21:53 UTC, Marc Schütz wrote: I'd say, if `shared` is required, but it compiles without, then it's still a bug. Yeah, probably so. Interestingly, without 'shared' and using a simple assignment from a constant (means[i]= 1.0;), instead of assignment from the sum() evaluation, results in all the values being initialized, so not marking it shared doesn't protect it from being written from the other thread. Anyway, the shared declaration doesn't seem to slow the execution, and it does make sense to me that it should be marked shared.
Dub pre-build hook
Is there a way to write a pre-build hook in Dub? Specifically, I want to write unittests in a separate package to the rest of my source code. This requires a module that imports all my unittest modules. It's safer to automatically generate this than to rely on my memory. My other alternative is to write a D script that assembles this file and then invokes dub, and always invoke dub via that script.
Re: sliced().array compatibility with parallel?
On Sunday, 10 January 2016 at 03:23:14 UTC, Ilya wrote: I will add significantly faster pairwise summation based on SIMD instructions into the future std.las. --Ilya Wow! A lot of overhead in the debug build. I checked the computed values are the same. This is on my laptop corei5. dub -b release-nobounds --force parallel time msec:448 non_parallel msec:767 dub -b debug --force parallel time msec:2465 non_parallel msec:4962 on my corei7 desktop, the release-no bounds parallel time msec:161 non_parallel msec:571
Re: Function accepts const ubyte[], const char[], immutable ubyte[], immutable char[]
On Sunday, 10 January 2016 at 10:10:46 UTC, zabruk70 wrote: void myFunc(char[] arg) { ubyte[] arg2 = cast(ubyte[]) arg; ...} void myFunc(const(void)[] arg) { const(ubyte)[] arg2 = cast(const(ubyte)[]) arg; // use arg2 } A `const(void)[]` type can accept any array as input. void[] is any array, const means it will take immutable, const, and mutable as well. Then you cast it to one type to use it. what if additionally to written above, function shuld return ubyte[] or char[] ? That depends on what you're doing, but you might also just want to return const(void)[], which the user will have to cast to something for them to use.
Re: sliced().array compatibility with parallel?
On Sunday, 10 January 2016 at 12:11:39 UTC, Russel Winder wrote: foreach( dv; dvp){ if(dv != dv){ // test for NaN return 1; } } return(0); } I am not convinced these "Tests for NaN" actually test for NaN. I believe you have to use isNan(dv). I saw it mentioned in another post, and tried it. Works.
[Dlang] Delegate Syntax Question
Hello. So I was trying to pass a delegate as an argument in a function and was wondering if I'm writing the correct code for it. You see my code is : // class Foo() { void bar() { writeln("Hello World"); } } class Bar() { void delegate() action; void setAction(void delegate() dele) { action = dele; } } void main() { Foo foo = new Foo(); Bar bar = new Bar(); bar.setAction(); bar.action(); } / Is this correct? Because I've been having trouble calling the delegate when passing the method and I read many documentation concerning function and delegates. I'm just confused. (Disclaimer: My code's pattern is the same as above but it's not really my exact code)
Re: [Dlang] Delegate Syntax Question
On 10.01.2016 15:32, Jack wrote: // class Foo() Those parentheses make this a (zero parameter) class template. I suppose you just want a plain class. Drop them then. { void bar() { writeln("Hello World"); } } class Bar() ditto { void delegate() action; void setAction(void delegate() dele) { action = dele; } } void main() { Foo foo = new Foo(); Bar bar = new Bar(); bar.setAction(); bar.action(); } / Is this correct? Because I've been having trouble calling the delegate when passing the method and I read many documentation concerning function and delegates. I'm just confused. (Disclaimer: My code's pattern is the same as above but it's not really my exact code) Aside from the mentioned parentheses (and a missing import), everything's correct.
Re: Linking a DLL to a DLL with packages
Am 09.01.2016 um 16:45 schrieb Thalamus: Hi Benjamin, I wouldn't say I need DLLs to work fully _really_ badly. The only non-negligible issue with single very large binaries that's crossed my mind is patching, but we're years away from having to worry about that too much. That being said, I'm definitely willing to do some testing, especially for something that helps us down the road. I'll follow up with you offline. Thanks! Great, some help with bugfixing and testing would be greatly apreciated. I didn't get any e-mail from you yet, I assume you didn't send one? Kind Regards Benjamin Thaut
Re: Variant and immutable struct
Okay, I've cleared up some misconception. On Wednesday, 6 January 2016 at 03:22:47 UTC, Vlad Leberstein wrote: The same happens with immutable class(there is related thread with workaround at http://www.digitalmars.com/d/archives/digitalmars/D/learn/Sending_an_immutable_object_to_a_thread_73866.html) This is irrelevant here. On Wednesday, 6 January 2016 at 03:22:47 UTC, Vlad Leberstein wrote: I'm trying to put an immutable struct into std.variant.Variant but get some compilation error(but only when struct has at least one member). Stripped down example(tested on Linux dmd64 v2.069.2): import std.variant : Variant; immutable struct Test { int member; } int main() { Test v; Variant test = v; return 0; } Qualifier applied to definition of aggregate type just marks all it's members with the qualifier and doesn't change the type itself(as I thought initially). So the problem with current implementation of std.variant.Variant is that it tries to modify(from the point of view of Type System) existing struct instance containing immutable members. I've done a little bit of hacking on Variant and came up with the following modification of "tryPutting": ... static bool tryPutting(A* src, TypeInfo targetType, void* target) { alias UA = Unqual!A; alias MutaTypes = TypeTuple!(UA, ImplicitConversionTargets!UA); alias ConstTypes = staticMap!(ConstOf, MutaTypes); alias SharedTypes = staticMap!(SharedOf, MutaTypes); alias SharedConstTypes = staticMap!(SharedConstOf, MutaTypes); alias ImmuTypes = staticMap!(ImmutableOf, MutaTypes); static if (is(A == immutable)) alias AllTypes = TypeTuple!(ImmuTypes, ConstTypes, SharedConstTypes); else static if (is(A == shared)) { static if (is(A == const)) alias AllTypes = SharedConstTypes; else alias AllTypes = TypeTuple!(SharedTypes, SharedConstTypes); } else { static if (is(A == const)) alias AllTypes = ConstTypes; else alias AllTypes = TypeTuple!(MutaTypes, ConstTypes); } foreach (T ; AllTypes) { if (targetType != typeid(T)) { continue; } static if (is(typeof(*cast(T*) target = *src))) { T* zat = cast(T*) target; if (src) { assert(target, "target must be non-null"); *zat = *src; } } else static if ((is(T == const(U), U) || is(T == shared(U), U) || is(T == shared const(U), U) || is(T == immutable(U), U)) && is(typeof(*(cast(U*) (target)) = *(cast(UA*) src))) ) { U* zat = cast(U*) target; if (src) { assert(target, "target must be non-null"); *zat = *(cast(UA*) (src)); } } else static if(is(T == struct)) { if (src) { assert(target, "target must be non-null"); memcpy((cast(void*) target), (cast(const(void*)) src), A.sizeof); } } else { // type is not assignable if (src) assert(false, A.stringof); } return true; } return false; } ... As I'm not very good at D, I would like to get some feedback about this solutions' viability. AFAIU memcpy-ing struct here is safe because all target arguments ever passed to tryPutting are internal to implementation(and SHOULD be void-initialized but it's currently not working AFAIK). Maybe postblit should also be called for new instance, but I'm not sure about current state of qualified postblit. Any help would be greatly appreciated!
Re: Bug in csv or byLine ?
The bug has been fixed...
Re: Bug in csv or byLine ?
On Sunday, 10 January 2016 at 09:41:16 UTC, Keywan Ghadami wrote: On Friday, 8 January 2016 at 13:53:06 UTC, Guillaume Chatelet wrote: I still do not understand half of the syntax(still learning) but my guess is that it is a bug in the csv reader: In https://github.com/D-Programming-Language/phobos/blob/67c95e6de21d5d627e3c57128b4d6e332c82f785/std/csv.d line 1020 calls popfront on the input without checking that it input is empty. But this only happen in special case if the last line is \r\n if i understand it correctly. I might be totally wrong because it does not match your stackstrace and i did not yet understand everything about this. Yes. It looks like there is no case to handle '\r' - line endings correctly. https://github.com/D-Programming-Language/phobos/blob/67c95e6de21d5d627e3c57128b4d6e332c82f785/std/csv.d?L=1020#L1020 If '\r' is the last character it will fail, (because it tryes to read the next character). enum data = "name, surname, age Joe, Joker, 99\r"; // WILL FAIL import std.csv, std.stdio; void main(string[] args) { auto reader = csvReader(data); foreach(entry; reader) { writeln(entry); } } togrue
Re: Bug in csv or byLine ?
On Sunday, 10 January 2016 at 18:09:23 UTC, Tobi G. wrote: The bug has been fixed... Do you have a link for the fix? Is there a BugZilla entry?
Anyone using glad?
Seems like it is a very nice way to get into openGL from D. http://glad.dav1d.de/ I generated the bindings for all the latest versions of the various specifications. Does anyone have any tutorials that use this library effectively? There's this https://github.com/Dav1dde/glamour But not sure what it is(diff between it and glad). Says it's a wrapper to OpenGL... but does it use the glad generated bindings? It looks like I'd prefer this to derelict because it seems like it is a automatically generated binding... which means future extensibility and no "extra" stuff. Would be nice if it works with dub. How could I use it easily with dub as a local library? (create a dependency from a local file location) Thanks.
Re: Bug in csv or byLine ?
On Sunday, 10 January 2016 at 19:07:52 UTC, Jesse Phillips wrote: On Sunday, 10 January 2016 at 18:09:23 UTC, Tobi G. wrote: The bug has been fixed... Do you have a link for the fix? Is there a BugZilla entry? Yes sure.. https://issues.dlang.org/show_bug.cgi?id=15545 and the fix at github https://github.com/D-Programming-Language/phobos/pull/3917 togrue
Re: [Dlang] Delegate Syntax Question
On Sunday, 10 January 2016 at 14:32:02 UTC, Jack wrote: ... Just to make your code a little more clear, try using aliases when defining delegate parameters. Like this: alias Action = void delegate(); Then in your code you use the alias, like this: class Bar() { private Action _action; void setAction(Action d) { this._action = d; } } IMHO it makes everything more readable and you only have one definition of the delegate signature.
Re: Function accepts const ubyte[], const char[], immutable ubyte[], immutable char[]
On Sunday, 10 January 2016 at 14:17:28 UTC, Adam D. Ruppe wrote: A `const(void)[]` type can accept any array as input. void[] is Ah, how i can forget about void[] ! Thanks Adam!
cairo(D) / x64 / unresolved externals / don't know why
I made to compile a bunch of libs on Win64 and got my D project compiled as well. Only problem left are some strange unresolved externals. Linking... dmd -of.dub\build\application-debug-windows-x86_64-dmd_2069-F0A1450B9B033D5CD11F3F60481557B0\webchat.exe .dub\build\application-debug-windows-x86_64-dmd_2069-F0A1450B9B033D5CD11F3F60481557B0\webchat.obj ..\vibe-d-0.7.26\lib\win-amd64\libeay32.lib ..\vibe-d-0.7.26\lib\win-amd64\ssleay32.lib ..\cairoD\cairoD.lib C:\Users\robby\AppData\Roaming\dub\packages\derelict-ft-1.0.2\lib\DerelictFT.lib C:\Users\robby\AppData\Roaming\dub\packages\derelict-util-2.0.4\lib\DerelictUtil.lib C:\Users\robby\AppData\Roaming\dub\packages\x11-1.0.9\x11.lib ..\vibe-d-0.7.26\vibe-d.lib wsock32.lib ws2_32.lib advapi32.lib user32.lib -LD:\develop\cairo\cairo\src\release\cairo-static.lib -LD:\develop\cairo\libpng\libpng.lib -Lgdi32.lib -m64 -m64 -m64 -m64 -m64 -m64 -g cairo-static.lib(cairo-image-source.obj) : error LNK2001: unresolved external "__imp__hypot" and some more missing in other .obj files: "__imp__ctime64" "__imp_ldiv" "__imp_strncpy" "__imp_rand" IMO this all looks like msvcrt standard lib stuff so wondering why it's not found. Do I explicitly have to link to the msvcrt lib? -- Robert M. Münch http://www.saphirion.com smarter | better | faster
Re: Anyone using glad?
On Sunday, 10 January 2016 at 21:53:45 UTC, Dav1d wrote: On Sunday, 10 January 2016 at 21:30:32 UTC, Jason Jeffory wrote: Seems like it is a very nice way to get into openGL from D. http://glad.dav1d.de/ I generated the bindings for all the latest versions of the various specifications. Does anyone have any tutorials that use this library effectively? There's this https://github.com/Dav1dde/glamour But not sure what it is(diff between it and glad). Says it's a wrapper to OpenGL... but does it use the glad generated bindings? It looks like I'd prefer this to derelict because it seems like it is a automatically generated binding... which means future extensibility and no "extra" stuff. Would be nice if it works with dub. How could I use it easily with dub as a local library? (create a dependency from a local file location) Thanks. Hey, I am the guy behind glad, you are most likely looking for: https://github.com/Dav1dde/glad#d Instead of downloading the glad sources and installing Python you can use the website http://glad.dav1d.de/ (If I have time I will write more documentation and also have it on the website) glad is just another way to load your OpenGL functions (kinda like Derelict does it), the main difference is, it exactly allows you to generate the feature set you need, if you're in doubt, you can also just generate everything. Another difference is, it uses the official XML-Specification files, so it is always up to date and doesn't need to be maintained. This also means it can can generate files for EGL/GLES/WGL and GLX. Glad itself is a library which happens to include a D generator 'backend', that allows you to extend it and make a more advanced loader (e.g. introduce another layer and automatically check glGetError, see C/C++ Debug), but for your normal use the included generator is good enough. Usage: Basically you download the zip, add the source files to your project and build system and call gladLoadGL() (check the return value, `enforce(gladLoadGL())`) after creating a context. This will use the internal loader, if you use glfw you can pass glfwGetProcAddress to gladLoadGL(), if you use SDL you can use SDL_GL_GetProcAddress: `gladLoadGL(x => glfwGetProcAddress(x))`. Then you can just go ahead and call the imported gl functions. Why no dub?: Well why would you want to use dub? Just generate the files and copy them into your source. I also wrote glamour, glamour is just a library which abstracts the the OpenGL API and has some glue code for gl3n (maths), SDL (texture loading), glad/Derelict (for gl). Cool, it looks really well done. I spend several hours researching and looking at various approaches. It was basically Derelict stuff or a lot of things that didn't look well done. I was wishing there was something that would automatically do it(looked into htod, swift, etc)... then I stumbled across your work!!! Was exactly what I wanted! glfw is separate or have you done something with it(is it wgl?)? I'm basically trying to get a minimal setup running on winx64. I don't want a lot of hassle that other "solutions" seem to have(no derelict, sdl, etc...). I know there has to be some windows stuff(glfw) haven't yet found a solution for it(haven't really looked yet).
Re: Anyone using glad?
On Sunday, 10 January 2016 at 21:30:32 UTC, Jason Jeffory wrote: Seems like it is a very nice way to get into openGL from D. http://glad.dav1d.de/ I generated the bindings for all the latest versions of the various specifications. Does anyone have any tutorials that use this library effectively? There's this https://github.com/Dav1dde/glamour But not sure what it is(diff between it and glad). Says it's a wrapper to OpenGL... but does it use the glad generated bindings? It looks like I'd prefer this to derelict because it seems like it is a automatically generated binding... which means future extensibility and no "extra" stuff. Would be nice if it works with dub. How could I use it easily with dub as a local library? (create a dependency from a local file location) Thanks. I preferred glad over derelict when I did some opengl work with D because it was easier to just include only the functions I wanted. Derelict made much bigger binaries, not sure how much in part that was to the whole kitchen sink approach or the derelict utility itself. However, both are great and work fine. Their analogues in C/C++ would be function pointer loaders like glew for derelict or opengl binding generators like glLoadGen(and glad, it's multi-language — I actually preferred it for C++ too) for glad. Bye.
Re: ndslice, using a slice in place of T[] in template parameters
On Sunday, 10 January 2016 at 22:23:18 UTC, Ilya Yaroshenko wrote: Could you please provide full code and error (git gists)? -- Ilya ok, thanks. I'm building with DMD32 D Compiler v2.069.2 on Win32. The dub.json is included. https://gist.github.com/jnorwood/affd05b69795c20989a3
Re: ndslice, using a slice in place of T[] in template parameters
On Sunday, 10 January 2016 at 23:24:24 UTC, Jay Norwood wrote: On Sunday, 10 January 2016 at 22:23:18 UTC, Ilya Yaroshenko wrote: Could you please provide full code and error (git gists)? -- Ilya ok, thanks. I'm building with DMD32 D Compiler v2.069.2 on Win32. The dub.json is included. https://gist.github.com/jnorwood/affd05b69795c20989a3 Just use normal arrays for buffer (median accepts array on second argument for optimisation reasons). BTW, dip80-ndslice moved to http://code.dlang.org/packages/mir -- Ilya
Re: Anyone using glad?
On Sunday, 10 January 2016 at 23:14:33 UTC, Dav1d wrote: On Sunday, 10 January 2016 at 22:37:28 UTC, Jason Jeffory wrote: [...] I would recommend using glfw for a context/window, there is a binding in Deimos https://github.com/D-Programming-Deimos/glfw - You need to either compile it yourself or just download the pre compiled package from the website and get the .lib file (http://www.glfw.org/). There is also an abstraction I wrote once: https://github.com/Dav1dde/glwtf not sure if it still works, it *should*. But even without the abstraction, getting a window and context up with glfw is really easy (documentation is really good! http://www.glfw.org/documentation.html). There is also a C++ example using glad: https://github.com/Dav1dde/glad/blob/master/example/c%2B%2B/hellowindow2.cpp which can easily be ported to D. Basically all you need is glfw and glad to get started! OK, I'll give it a try. What about GLUT and WGL? Whats the difference between them all and glfw? Are all these just OS helpers to reduce the boilerplate code? Also, how hard would it be to support cgl? (mac bindings) Thanks!
Re: Anyone using glad?
On Sunday, 10 January 2016 at 22:37:28 UTC, Jason Jeffory wrote: On Sunday, 10 January 2016 at 21:53:45 UTC, Dav1d wrote: On Sunday, 10 January 2016 at 21:30:32 UTC, Jason Jeffory wrote: [...] Hey, I am the guy behind glad, you are most likely looking for: https://github.com/Dav1dde/glad#d Instead of downloading the glad sources and installing Python you can use the website http://glad.dav1d.de/ (If I have time I will write more documentation and also have it on the website) glad is just another way to load your OpenGL functions (kinda like Derelict does it), the main difference is, it exactly allows you to generate the feature set you need, if you're in doubt, you can also just generate everything. Another difference is, it uses the official XML-Specification files, so it is always up to date and doesn't need to be maintained. This also means it can can generate files for EGL/GLES/WGL and GLX. Glad itself is a library which happens to include a D generator 'backend', that allows you to extend it and make a more advanced loader (e.g. introduce another layer and automatically check glGetError, see C/C++ Debug), but for your normal use the included generator is good enough. Usage: Basically you download the zip, add the source files to your project and build system and call gladLoadGL() (check the return value, `enforce(gladLoadGL())`) after creating a context. This will use the internal loader, if you use glfw you can pass glfwGetProcAddress to gladLoadGL(), if you use SDL you can use SDL_GL_GetProcAddress: `gladLoadGL(x => glfwGetProcAddress(x))`. Then you can just go ahead and call the imported gl functions. Why no dub?: Well why would you want to use dub? Just generate the files and copy them into your source. I also wrote glamour, glamour is just a library which abstracts the the OpenGL API and has some glue code for gl3n (maths), SDL (texture loading), glad/Derelict (for gl). Cool, it looks really well done. I spend several hours researching and looking at various approaches. It was basically Derelict stuff or a lot of things that didn't look well done. I was wishing there was something that would automatically do it(looked into htod, swift, etc)... then I stumbled across your work!!! Was exactly what I wanted! glfw is separate or have you done something with it(is it wgl?)? I'm basically trying to get a minimal setup running on winx64. I don't want a lot of hassle that other "solutions" seem to have(no derelict, sdl, etc...). I know there has to be some windows stuff(glfw) haven't yet found a solution for it(haven't really looked yet). I would recommend using glfw for a context/window, there is a binding in Deimos https://github.com/D-Programming-Deimos/glfw - You need to either compile it yourself or just download the pre compiled package from the website and get the .lib file (http://www.glfw.org/). There is also an abstraction I wrote once: https://github.com/Dav1dde/glwtf not sure if it still works, it *should*. But even without the abstraction, getting a window and context up with glfw is really easy (documentation is really good! http://www.glfw.org/documentation.html). There is also a C++ example using glad: https://github.com/Dav1dde/glad/blob/master/example/c%2B%2B/hellowindow2.cpp which can easily be ported to D. Basically all you need is glfw and glad to get started!
Re: ndslice, using a slice in place of T[] in template parameters
On Sunday, 10 January 2016 at 23:31:47 UTC, Ilya Yaroshenko wrote: Just use normal arrays for buffer (median accepts array on second argument for optimisation reasons). ok, I think I see. I created a slice(numTasks, bigd) over an allocated double[] dbuf, but slb[task] will be returning some struct instead of the double[] that i need in this case. If I add .array to the Slice, it does compile, and executes, but slower than using the buffer directly. medians[i] = median(vec, slb[task].array); parallel time medians msec:113 original version using the computed slice of the original allocated dbuf. medians[i] = median(vec,dbuf[j .. k]); parallel time medians msec:85 The .array appears to make a copy. Is there some other call in ndslice to return the double[] slice of the original array?
Re: ndslice, using a slice in place of T[] in template parameters
On Monday, 11 January 2016 at 00:39:04 UTC, Jay Norwood wrote: On Sunday, 10 January 2016 at 23:31:47 UTC, Ilya Yaroshenko wrote: Just use normal arrays for buffer (median accepts array on second argument for optimisation reasons). ok, I think I see. I created a slice(numTasks, bigd) over an allocated double[] dbuf, but slb[task] will be returning some struct instead of the double[] that i need in this case. If I add .array to the Slice, it does compile, and executes, but slower than using the buffer directly. medians[i] = median(vec, slb[task].array); parallel time medians msec:113 original version using the computed slice of the original allocated dbuf. medians[i] = median(vec,dbuf[j .. k]); parallel time medians msec:85 The .array appears to make a copy. Is there some other call in ndslice to return the double[] slice of the original array? I will add such function. But it is not safe to do so (Slice can have strides not equal to 1). So it is like a hack ([0, 0, 0])[0 .. ret.elementsCount]). Have you made comparison between my and yours parallel versions? https://github.com/9il/examples/blob/parallel/image_processing/median-filter/source/app.d -- Ilya
ndslice, using a slice in place of T[] in template parameters
I cut this median template from Jack Stouffer's article and was attempting to use it in a parallel function. As shown, it builds and execute correctly, but it failed to compile if I attempting to use medians[i] = median(vec,slb[task]); in place of the medians[i] = median(vec,dbuf[j .. k]); Is there a cast needed? import std.array : array; import std.algorithm; import std.datetime; import std.conv : to; import std.stdio; import std.experimental.ndslice; shared double[] medians; double[] data; shared double[] dbuf; int numTasks; const int smalld = 1000; const int bigd = 10_000; const int fulld = bigd*smalld; /** Params: r = input range buf = buffer with length no less than the number of elements in `r` Returns: median value over the range `r` */ T median(Range, T)(Range r, T[] buf) { import std.algorithm.sorting: sort; size_t n; foreach (e; r) { buf[n++] = e; } buf[0 .. n].sort(); immutable m = n >> 1; return n & 1 ? buf[m] : cast(T)((buf[m - 1] + buf[m]) / 2); } void f3() { import std.parallelism; auto sl = data.sliced(smalld,bigd); auto slb = dbuf.sliced(numTasks,bigd); foreach(i,vec; parallel(sl)){ int task = taskPool.workerIndex; int j = task*bigd; int k = j+bigd; medians[i] = median(vec,dbuf[j .. k]); } } void main() { import std.parallelism; numTasks = taskPool.size+1; data = new double[fulld]; dbuf = new double[bigd*numTasks]; medians = new double[smalld]; for(int i=0;i
Re: ndslice, using a slice in place of T[] in template parameters
On Sunday, 10 January 2016 at 22:00:20 UTC, Jay Norwood wrote: I cut this median template from Jack Stouffer's article and was attempting to use it in a parallel function. As shown, it builds and execute correctly, but it failed to compile if I attempting to use medians[i] = median(vec,slb[task]); [...] Could you please provide full code and error (git gists)? -- Ilya
Re: ndslice, using a slice in place of T[] in template parameters
On Sunday, 10 January 2016 at 23:24:24 UTC, Jay Norwood wrote: On Sunday, 10 January 2016 at 22:23:18 UTC, Ilya Yaroshenko wrote: Could you please provide full code and error (git gists)? -- Ilya ok, thanks. I'm building with DMD32 D Compiler v2.069.2 on Win32. The dub.json is included. https://gist.github.com/jnorwood/affd05b69795c20989a3 I have create parallel test to (it requires mir v0.10.0-beta ) https://github.com/9il/examples/blob/parallel/image_processing/median-filter/source/app.d Could you please create a benchmark with default values of nc & nc for single thread app, your parallel version, and my. My version has some additional overhead and I am interesting if it is significant. -- Ilya
Re: Anyone using glad?
On Sunday, 10 January 2016 at 21:30:32 UTC, Jason Jeffory wrote: Seems like it is a very nice way to get into openGL from D. http://glad.dav1d.de/ I generated the bindings for all the latest versions of the various specifications. Does anyone have any tutorials that use this library effectively? There's this https://github.com/Dav1dde/glamour But not sure what it is(diff between it and glad). Says it's a wrapper to OpenGL... but does it use the glad generated bindings? It looks like I'd prefer this to derelict because it seems like it is a automatically generated binding... which means future extensibility and no "extra" stuff. Would be nice if it works with dub. How could I use it easily with dub as a local library? (create a dependency from a local file location) Thanks. Hey, I am the guy behind glad, you are most likely looking for: https://github.com/Dav1dde/glad#d Instead of downloading the glad sources and installing Python you can use the website http://glad.dav1d.de/ (If I have time I will write more documentation and also have it on the website) glad is just another way to load your OpenGL functions (kinda like Derelict does it), the main difference is, it exactly allows you to generate the feature set you need, if you're in doubt, you can also just generate everything. Another difference is, it uses the official XML-Specification files, so it is always up to date and doesn't need to be maintained. This also means it can can generate files for EGL/GLES/WGL and GLX. Glad itself is a library which happens to include a D generator 'backend', that allows you to extend it and make a more advanced loader (e.g. introduce another layer and automatically check glGetError, see C/C++ Debug), but for your normal use the included generator is good enough. Usage: Basically you download the zip, add the source files to your project and build system and call gladLoadGL() (check the return value, `enforce(gladLoadGL())`) after creating a context. This will use the internal loader, if you use glfw you can pass glfwGetProcAddress to gladLoadGL(), if you use SDL you can use SDL_GL_GetProcAddress: `gladLoadGL(x => glfwGetProcAddress(x))`. Then you can just go ahead and call the imported gl functions. Why no dub?: Well why would you want to use dub? Just generate the files and copy them into your source. I also wrote glamour, glamour is just a library which abstracts the the OpenGL API and has some glue code for gl3n (maths), SDL (texture loading), glad/Derelict (for gl).
Setting up dmd properly
Dmd's setup construction is a bit weird and has some difficult issue tracking. How about if dmd supported, if it already doesn't, some ways to help the user check the configuration of dmd. It would be quick and easy to implement. e.g., dmd -showinfo Target Arch: x86 Libraries: C:\Mylib;C:\Another\Lib\Somewhere Modules: C:\MyModules; Version: 2.062 etc... This way, issues between 64 and 32 paths can easily be seen... figuring out exactly what sc.ini is doing is easier, etc... We know it is accurate because it would come from the compiler itself. No guessing. Probably a dmd app could be created that does this instead? Basically I've ran into issues before setting up D because of path issues(again, the sc.ini file is pretty crappy... littered with duplicate symbols and different paths with "hacks" for different compilers and all that(it's just not sain)). It tends to make me hesitant dealing with dmd in some cases. Something that should take a min to do can take hours trying to track down some weird issue simply because of a typo... and there's no way to know exactly what the compiler is "seeing"... I really hope something like this already exists.
Re: Setting up dmd properly
On Monday, 11 January 2016 at 01:22:28 UTC, Jason Jeffory wrote: Dmd's setup construction is a bit weird and has some difficult issue tracking. How about if dmd supported, if it already doesn't, some ways to help the user check the configuration of dmd. It would be quick and easy to implement. e.g., dmd -showinfo Target Arch: x86 Libraries: C:\Mylib;C:\Another\Lib\Somewhere Modules: C:\MyModules; Version: 2.062 etc... This way, issues between 64 and 32 paths can easily be seen... figuring out exactly what sc.ini is doing is easier, etc... We know it is accurate because it would come from the compiler itself. No guessing. Probably a dmd app could be created that does this instead? Basically I've ran into issues before setting up D because of path issues(again, the sc.ini file is pretty crappy... littered with duplicate symbols and different paths with "hacks" for different compilers and all that(it's just not sain)). It tends to make me hesitant dealing with dmd in some cases. Something that should take a min to do can take hours trying to track down some weird issue simply because of a typo... and there's no way to know exactly what the compiler is "seeing"... I really hope something like this already exists. Also, any linked in libraries could report there format and such. I've had problems figuring out certain coeff libs issues and all that. Knowing exactly what's going on is a good thing, right?!?!?