Re: Does dmd use static or dynamic linking with the Phobos Library?
On Tuesday, 1 May 2012 at 02:47:35 UTC, Nick Sabalausky wrote: "WhatMeWorry" wrote in message news:ezfjpijdnokmihhrp...@forum.dlang.org... Is this user configurable? I came across the sentence in the D Compiler/Linking section: "The actual linking is done by running gcc" I thought that maybe this meant that I could pass a gcc option like -static or -shared through dmd, but it errored out. Thanks in advance. Static. Dynamic linking with Phobos is currently being worked on. I should also have read more before posting. Just found this link. http://prowiki.org/wiki4d/wiki.cgi?D__Tutorial/CompilingLinkingD#Linkingmanually
Re: Compute in one pass 3 tokens position
On Tuesday, 1 May 2012 at 02:49:19 UTC, bioinfornatics wrote: Le lundi 30 avril 2012 à 14:52 +0200, bioinfornatics a écrit : Anyone know how to know the position of 3 token in one sequence in one pass? tok1 = a tok2 = b tok3 = c seq = blah count me b=> 0 a=>2 c=>5 iterate over sequence if token not yet seen count the number of iteration for know in which column it is located. Example own written on the fly) I would say you are trying to way overcomplicated the solution. For simplicity I would use an AA, then a foreach and it will do it in 1 pass (2 if you count the inner ones). I'm not sure if there's a better solution already in phobos, so I can't refer to that :( This could be modified to be more generic so.. //returns AA of tokens that were found and the offset of their first occurrence. int[char] findTokens(const char[] input, char[] tok ...) { int[char] offs; foreach(i, ch; input) { foreach(t; tok) { if (ch == t && t !in offs) offs[t] = i; } } return offs; } unittest { assert(findTokens("blah count me", 'a', 'b', 'c') == ['a':2, 'b' : 0, 'c':5]); }
Re: Compute in one pass 3 tokens position
Le lundi 30 avril 2012 à 14:52 +0200, bioinfornatics a écrit : > Hi, > I would like to know how compute in on pass 3 tokens position in a > sequence. > curently i do: > File f = File( "reader.d", "r" ); > scope(exit) f.close(); > char[1024] buffer; > char[] content = f.rawRead(buffer); > char[sizediff_t] token = ['(', '{', ';']; > auto position = map!( a => content.countUntil( a ) )( [ ['('], ['{'], > [';'] ] ); > > > if i use reduce instead map the build fail > Anyone know how to know the position of 3 token in one sequence in one pass? tok1 = a tok2 = b tok3 = c seq = blah count me b=> 0 a=>2 c=>5 iterate over sequence if token not yet seen count the number of iteration for know in which column it is located. Example own written on the fly) sizediiff_t[] countUntil( in char[] seq; char[] tokens ){ bool isSearching = true; size_t index = 0; sizediiff_t[] position = new sizediiff_t[](tokens.length); while (isSearching){ if (index >⁼ seq.length) isSearching = false; else if (! find( position, -1) // al token found we can stop; isSearching = false; else{ sizediiff_t tmp = countUntil( tokens, [seq[index]]); if (countUntil( tmp != -1 && position[tmp] != -1) position[tmp] = index; index++; } } }
Re: Does dmd use static or dynamic linking with the Phobos Library?
"WhatMeWorry" wrote in message news:ezfjpijdnokmihhrp...@forum.dlang.org... > > Is this user configurable? I came across the sentence in the D > Compiler/Linking section: > > "The actual linking is done by running gcc" > > I thought that maybe this meant that I could pass a gcc option > like -static or -shared through dmd, but it errored out. > > Thanks in advance. > Static. Dynamic linking with Phobos is currently being worked on.
Does dmd use static or dynamic linking with the Phobos Library?
Is this user configurable? I came across the sentence in the D Compiler/Linking section: "The actual linking is done by running gcc" I thought that maybe this meant that I could pass a gcc option like -static or -shared through dmd, but it errored out. Thanks in advance.
Frustration [Was: mysql binding/wrapper?]
On 5/1/12 2:44 AM, simendsjo wrote: On Mon, 30 Apr 2012 20:55:45 +0200, Ary Manzana wrote: Looking at the code of mysql.d I see a big switch with many cases like "case 0x01: // TINYINT". But then there's the SQLType enum with those constants. Why the enum values are not used in the cases? (and also in other parts of the code?) It's not finished: http://www.britseyeview.com/software/mysqln/ Ah, I see. The last commit is 6 months old. I tried to compile mysql.d --- > dmd -c mysql.d /usr/share/dmd/src/phobos/std/exception.d(492): Error: constructor mysql.MySQLException.this (string msg, string file, uint line) is not callable using argument types (string,string,ulong) /usr/share/dmd/src/phobos/std/exception.d(492): Error: cannot implicitly convert expression (line) of type ulong to uint mysql.d(105): Error: template instance std.exception.enforceEx!(MySQLException).enforceEx!(ulong) error instantiating (...) (and more...) --- It's sad. I always want to give D a chance. And when I do I always bump into errors and inconveniences. I thought, maybe the project is 6 months old, it's not compatible anymore with the current DMD (but my code really doesn't break at all with new Ruby versions, for example). I thought of trying to fix the error. Apparently I need to compile it with -m32 so that lengths of arrays are uint instead of ulong. --- > dmd -c -m32 mysql.d mysql.d(4185): Error: cannot cast r.opIndex(cast(uint)j).get!(ulong) mysql.d(4201): Error: cannot cast r.opIndex(cast(uint)j).get!(ulong) mysql.d(4204): Error: cannot cast r.opIndex(cast(uint)j).get!(ulong) --- (What does it mean "cannot cast"? Give me the reason, please...) Or maybe instead of the flag the code is wrong and instead of uint it needs to be size_t. But I still get errors. Every time I want to start coding in D, or helping some project, I stumble into all kind of troubles. But I wonder... is this case in particular D's fault or the library's fault? (if the answer is "the project is 6 months old, of course it won't compile" then it's D's fault)
Re: is there a difference between those two notations
On 04/30/2012 05:19 PM, Christian Köstlin wrote: reduce!((int a, int b){return a+b;})(iota(100)) reduce!("a+b")(iota(100)) thanks in advance christian koestlin In this case there is not. But if external symbols are to be referred to inside the lambda, then the second notation cannot be used.
Re: Derelict2 openGL3 issues
On Tuesday, 24 April 2012 at 08:45:44 UTC, Denis Shelomovskij wrote: One day I'll finish my OpenGL wrapper for D. It will give you better abilities in creating OpenGL 3 contexts than most C++ frameworks (SDL, GLFW etc.) and, I hope, will get rid of passing pointers to functions. It will be done soon after I'll finish Scintilla wrapper for D. And it will be done soon after I'll conquer the world (or a bit earlier). Dreams, dreams... P.S. OpenGL context creating has been done a long time ago but then I decided to create full wrapper to supersede Derelict's one and it still not finished because that I decided to create general wrapping back-end. And I've done it (CWrap), but than I decided to create Scintilla wrapper... P.P.S. Sorry for the flood... -- Денис В. Шеломовский Denis V. Shelomovskij One of the reasons I came to D is because I can feed and read data from openGL using pointers rather than having to duplicate (Marshal) data from the stack to the managed heap before I can interact with openGL (C#). It is redundant to be reading vertex attribute data from a file into managed memory when the destination of that data is the graphics card. It is better to be reading the file data into a stack based struct, handing the pointer to this data to the vbo, securing the vao id and then dropping the stack at function exit. If for no other reason it reduces the work required by the garbage collector continuously reorganizing the heap as vertex data transits through it.
Re: is there a difference between those two notations
Christian Köstlin: reduce!((int a, int b){return a+b;})(iota(100)) reduce!("a+b")(iota(100)) Today the syntaxes I prefer are: iota(100).reduce!q{a + b}() iota(100).reduce!((a, b) => a + b)() But hopefully in some we'll have an efficient sum() function too in Phobos: iota(100).sum() Bye, bearophile
Re: Help: running a method from the importing file's method "space"
With MyLib obviously containing the MyLibInit(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR CmdLine, int CmdShow) method.
Re: Help: running a method from the importing file's method "space"
On Monday, 30 April 2012 at 18:54:41 UTC, Era Scarecrow wrote: On Monday, 30 April 2012 at 18:50:24 UTC, Era Scarecrow wrote: Add 'import test;' to your MyLib module. Although that seems like it's connecting a library to something it shouldn't... In which case perhaps a delegate passed to the library to call myProg? Doesn't seem right either. What is your library suppose to do? And why should it have to access something outside it's library set? (Unless test.d is part of the library) I make this library to create a few classes for creating some simple GUI components (window, buttons, text boxes, that's about it) as a bit of a learning exercise, and for practical use. "test.d" is not part of the library, it is just for testing the library. What I could do that would definatly work is: -- File "test.d": -- import core.runtime; import core.sys.windows.windows; import MyLib; pragma(lib, "MyLib.lib); extern(Windows) { WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR CmdLine, int CmdShow) { MyLibInit(hInst, hPrevInst, CmdLine, CmdShow); } ENDFILE So I can then just pass everything my lib requires to it and then there is no need for progMain. I'm asking this question as with QT's source, it uses WinMain: https://qt.gitorious.org/qt/qt/blobs/HEAD/src/winmain/qtmain_win.cpp 80 /* 81 WinMain() - Initializes Windows and calls user's startup function main(). 82 NOTE: WinMain() won't be called if the application was linked as a "console" 83application. 84 */ 85 86 #ifdef Q_OS_WINCE 87 int WINAPI WinMain(HINSTANCE instance, HINSTANCE prevInstance, LPWSTR /*wCmdParam*/, int cmdShow) Yet you can still use "main()" from your program and then link to QT's dll and use its functionality. I know that is C++ but that's where I'm comming from with this. I think you are right and my library isn't supposed to try access "test.d"'s methods, classes, etc. and be self contained. So should I rather go with the WinMain in my main program then pass the parameters to MyLib like I showed before the QT reference?
Re: mysql binding/wrapper?
On Mon, 30 Apr 2012 20:55:45 +0200, Ary Manzana wrote: Looking at the code of mysql.d I see a big switch with many cases like "case 0x01: // TINYINT". But then there's the SQLType enum with those constants. Why the enum values are not used in the cases? (and also in other parts of the code?) It's not finished: http://www.britseyeview.com/software/mysqln/
Re: Help: running a method from the importing file's method "space"
On Monday, 30 April 2012 at 19:22:35 UTC, Rowan wrote: Add 'import test;' to your MyLib module. That does work, but I didn't want to change the source of MyLib, I dunno maybe what I'm asking isn't possible. Is there a reason the library needs to call outside of it's own library access? When I think of a library it's suppose to be self contained. Perhaps just the approach is wrong?
Re: mysql binding/wrapper?
On Mon, 30 Apr 2012 20:53:02 +0200, James Oliphant wrote: On Mon, 30 Apr 2012 18:57:57 +0200, simendsjo wrote: Yes, your patches has been merged. Of course it would be best to have everything database complete already, but I'm glad it's been merged as-is for now - it might take a long time (and has already) before a generic database interface is completed. Hi simendsjo, I now see your repository at: https://github.com/simendsjo/mysqln Is there a way that we can have one central repository that people can pull from. I would like it to be Steve's since that is the one everybody knows, but I am not sure he wants to manage pull requests and such (If your are listening Steve, please weigh in). He seems to be enjoying "Adventures in Woodworking" and may not have any fingers left when he finishes his latest project (just joking, read your blog). Otherwise, maybe we could use your repository listed above. My goal is not a generic database interface discussed previously in these groups. I just want an interface for mysql/mariadb and less so for postgresql at this point. I did a small patch for it to compile for x64. Vibe.d has patches to use it's internal stream library, so that would probably be hard to patch back to Steve. I was thinking of deleting my project and forking from vibe.d to do pull requests against that as I thought that would be the most used repository Not sure how we should go about this, but I agree fragmentation is bad. Hope Steve can chip in as it's his code and he has plans for a generic interface.
Re: Help: running a method from the importing file's method "space"
Add 'import test;' to your MyLib module. That does work, but I didn't want to change the source of MyLib, I dunno maybe what I'm asking isn't possible.
Re: is there a difference between those two notations
On 04/30/2012 07:04 PM, Jonathan M Davis wrote: On Monday, April 30, 2012 17:19:00 Christian Köstlin wrote: reduce!((int a, int b){return a+b;})(iota(100)) reduce!("a+b")(iota(100)) thanks in advance The first one directly creates a lambda, whereas the second one uses a string mixin with std.function.binaryFunc to create a lambda. The lambda generated for the second one will be the same as the one given in the first. They're just different ways to do the same thing. - Jonathan M Davis thanks a lot ... should have had a look in https://github.com/D-Programming-Language/phobos/blob/master/std/algorithm.d ... regards christian koestlin
Re: mysql binding/wrapper?
On 4/30/12 11:57 PM, simendsjo wrote: On 4/29/12 11:48 PM, dnewbie wrote: On Saturday, 28 April 2012 at 15:30:13 UTC, simendsjo wrote: stuff/blob/master/mysql.d http://my.opera.com/run3/blog/2012/03/13/d-mysql I use it in a bank account application. It works. On Mon, 30 Apr 2012 18:19:29 +0200, James Oliphant wrote: Actually, it looks like the vibe folks are using my fork of Steve Teales mysqln. I had hoped to contact Steve first, so that these changes existed in one place. https://github.com/JollieRoger All of the changes exist in individual branches off the master branch. Git will merge these into one file fuzzily. What they are is as follows: seperatemain - split main() into its own file (app.d in vibe). seperatemainwithport - main() using branch addporttoconnection. addporttoconnection - add no standard port selection to Connection. fixfordmd2058 - cosmetic changes to work with dmd-2.058. fixresultset - allow the return of an empty resultset. When iterating schema, test had no tables and would crash. fixconnection - would only connect to localhost in Steve's code. I have other changes that I haven't pushed up yet relating to NUMERIC and null variants with a more detailed main.d. Vibe.d looks interesting, I hope these fixes help. Yes, your patches has been merged. Of course it would be best to have everything database complete already, but I'm glad it's been merged as-is for now - it might take a long time (and has already) before a generic database interface is completed. Looking at the code of mysql.d I see a big switch with many cases like "case 0x01: // TINYINT". But then there's the SQLType enum with those constants. Why the enum values are not used in the cases? (and also in other parts of the code?)
Re: Help: running a method from the importing file's method "space"
On Monday, 30 April 2012 at 18:50:24 UTC, Era Scarecrow wrote: Add 'import test;' to your MyLib module. Although that seems like it's connecting a library to something it shouldn't... In which case perhaps a delegate passed to the library to call myProg? Doesn't seem right either. What is your library suppose to do? And why should it have to access something outside it's library set? (Unless test.d is part of the library)
Re: mysql binding/wrapper?
On Mon, 30 Apr 2012 18:57:57 +0200, simendsjo wrote: > Yes, your patches has been merged. Of course it would be best to have > everything database complete already, but I'm glad it's been merged > as-is for now - it might take a long time (and has already) before a > generic database interface is completed. Hi simendsjo, I now see your repository at: https://github.com/simendsjo/mysqln Is there a way that we can have one central repository that people can pull from. I would like it to be Steve's since that is the one everybody knows, but I am not sure he wants to manage pull requests and such (If your are listening Steve, please weigh in). He seems to be enjoying "Adventures in Woodworking" and may not have any fingers left when he finishes his latest project (just joking, read your blog). Otherwise, maybe we could use your repository listed above. My goal is not a generic database interface discussed previously in these groups. I just want an interface for mysql/mariadb and less so for postgresql at this point.
Re: Help: running a method from the importing file's method "space"
On Monday, 30 April 2012 at 18:30:29 UTC, Rowan wrote: -- File: MyLib.d: -- module MyLib; import core.runtime; import core.sys.windows.windows; //import std.string; So if I want to make any file (in this case "test.d", which can just import MyLib after I have -lib'd it and use the custom "entry point" -> "progMain" after "MyLib" has gotten everything it needs from the WinMain entry point, so that the programmer (me) can now just import MyLib and start typing their code in progMain instead of the usual main() without having to alter the source of MyLib. Basically I want MyLib to be able to call test's "progMain()", as when I try I get some error along the lines of progMain() not existing. I hope someone understands me, if you do and have an answer could you give me a step by step way of doing this? Add 'import test;' to your MyLib module.
Help: running a method from the importing file's method "space"
Hi all, Two things first: 1) I am quite new to D and have been using Java at school and a bit of C++ at home so some things confuse me. Please bear with me. 2) Apologies about the ambiguity of the title, I have no idea how to ask this in just one line so I'll elaborate here: What I want to do is create a static library to create a small wrapper/ to the Win API GUI functions for some basic GUI components for some projects instead of using some of the already made and slightly bulky GUI libraries around for D. This is what gives me a problem explained below. I need the WinMain(...) entry point to be run so that I can get my window handle for many of the windows GUI functions so using main() is out, and I want WinMain to be in the library, so the entry point of the program is in the library not the importing file, so if I have my (simplified) files: -- File: MyLib.d: -- module MyLib; import core.runtime; import core.sys.windows.windows; //import std.string; extern(windows) { int WinMain(...) { int success; //Init code success = myWin(...); return success; } } int myWin(...) { progMain(); } //Other code... -- File: test.d (i.e. importing file): -- import MyLib; pragma(lib, "MyLib.lib"); void progMain() { //User TODO code... } So if I want to make any file (in this case "test.d", which can just import MyLib after I have -lib'd it and use the custom "entry point" -> "progMain" after "MyLib" has gotten everything it needs from the WinMain entry point, so that the programmer (me) can now just import MyLib and start typing their code in progMain instead of the usual main() without having to alter the source of MyLib. Basically I want MyLib to be able to call test's "progMain()", as when I try I get some error along the lines of progMain() not existing. I hope someone understands me, if you do and have an answer could you give me a step by step way of doing this? Thanks -Rowan
Re: DWT: synchronized toHash nothrow
On 30-04-2012 20:18, Jesse Phillips wrote: So I've been wanting to switch to DTW from DFL, but that isn't too relevant. I though I could start with a update of the library for 2.059. This has ended up going into areas of synchronous and nothrow that I'm not as familiar. I have hit public hash_t toHash(){ synchronized(this){ return this.list.toHash(); } } base\src\java\util\Collections.d(275): Error: _d_monitorenter is not nothrow base\src\java\util\Collections.d(275): Error: function java.util.Collections.Collections.SynchronizedList.toHash 'toHash' is nothrow yet may throw ok, but what do I do. Does _d_monitorenter actually need to be nothrow so we can synchronize inside such functions? Probably. On another note, I removed a bunch of "implMissing( __FILE__, __LINE__ );)" functions like toHash(). I think this is reasonable but thought I would ask. The workaround is: public hash_t toHash() { try synchronized (this) return this.list.toHash(); catch assert(false); } -- - Alex
DWT: synchronized toHash nothrow
So I've been wanting to switch to DTW from DFL, but that isn't too relevant. I though I could start with a update of the library for 2.059. This has ended up going into areas of synchronous and nothrow that I'm not as familiar. I have hit public hash_t toHash(){ synchronized(this){ return this.list.toHash(); } } base\src\java\util\Collections.d(275): Error: _d_monitorenter is not nothrow base\src\java\util\Collections.d(275): Error: function java.util.Collections.Collections.SynchronizedList.toHash 'toHash' is nothrow yet may throw ok, but what do I do. Does _d_monitorenter actually need to be nothrow so we can synchronize inside such functions? On another note, I removed a bunch of "implMissing( __FILE__, __LINE__ );)" functions like toHash(). I think this is reasonable but thought I would ask.
Re: is there a difference between those two notations
On Monday, April 30, 2012 17:19:00 Christian Köstlin wrote: > reduce!((int a, int b){return a+b;})(iota(100)) > reduce!("a+b")(iota(100)) > > thanks in advance The first one directly creates a lambda, whereas the second one uses a string mixin with std.function.binaryFunc to create a lambda. The lambda generated for the second one will be the same as the one given in the first. They're just different ways to do the same thing. - Jonathan M Davis
Re: type conversions
> Can the documentation of std.conv be fixed? > > http://dlang.org/phobos/std_conv.html#to > > I mean, all the toImpl methods are documented, but in "to" it clearly > says "Client code normally calls to!TargetType(value) (and not some > variant of toImpl." I think all the documentation should be in "to". Now > it sounds like you know what "to" does... but people read documentation > because they don't know what it does. The comment on to could obviously be changed, but it wouldn't be all that fun to try and not have toImpl in the documentation. You'd have to do something like version(StdDdoc) { /++ ddoc comment +/ T to(T, S)(S value) if(...) {assert(0);} } else { T toImpl(T, S)(S Value) if(...) {...} } for every toImpl, which would create undesirable code duplication on top of being ugly. You can certainly make the changes and create a pull request for them if you want to though. Another approach would simply be to put better examples in the documentation. The weird thing is that there's a huge comment with a variety of examples near the top of the file that looks an awful lot like it's intended to be the ddoc comment for the module, but it's not actually at the top of the module, nor is it on any symbol (and it specifically has a space after its first asterisk so that it's not a ddoc comment). It's also, right above to, so maybe it was intended to be on to at one point. Either way, it's a bit weird. - Jonathan M Davis
Re: mysql binding/wrapper?
On Mon, 30 Apr 2012 18:19:29 +0200, James Oliphant wrote: Actually, it looks like the vibe folks are using my fork of Steve Teales mysqln. I had hoped to contact Steve first, so that these changes existed in one place. https://github.com/JollieRoger All of the changes exist in individual branches off the master branch. Git will merge these into one file fuzzily. What they are is as follows: seperatemain - split main() into its own file (app.d in vibe). seperatemainwithport - main() using branch addporttoconnection. addporttoconnection - add no standard port selection to Connection. fixfordmd2058 - cosmetic changes to work with dmd-2.058. fixresultset - allow the return of an empty resultset. When iterating schema, test had no tables and would crash. fixconnection - would only connect to localhost in Steve's code. I have other changes that I haven't pushed up yet relating to NUMERIC and null variants with a more detailed main.d. Vibe.d looks interesting, I hope these fixes help. Yes, your patches has been merged. Of course it would be best to have everything database complete already, but I'm glad it's been merged as-is for now - it might take a long time (and has already) before a generic database interface is completed.
Re: is there a difference between those two notations
On Monday, 30 April 2012 at 15:19:02 UTC, Christian Köstlin wrote: reduce!((int a, int b){return a+b;})(iota(100)) reduce!("a+b")(iota(100)) thanks in advance christian koestlin The answer to your question should be no. The second is transformed into a delegate like the first during compilation. Note that there is also C# like lambdas (a, b) => a+b
Re: mysql binding/wrapper?
On Mon, 30 Apr 2012 16:18:16 +0200, simendsjo wrote: > On Mon, 30 Apr 2012 16:08:34 +0200, Steven Schveighoffer > wrote: > >> On Sat, 28 Apr 2012 13:42:41 -0400, Adam D. Ruppe >> wrote: >> >>> On Saturday, 28 April 2012 at 16:19:37 UTC, simendsjo wrote: Would you mind if the module was added to vibe, and thus relicensed to MIT? No idea if the vibe folks would actually want that though :) >>> >>> My stuff is all free to take as far as I'm concerned, but since this >>> uses libmysql it might technically be GPL. >> >> If that's the case, using this lib will make your entire project GPL. >> >> I think the britseyeview version was an attempt by Steve Teale to write >> a non-GPL lib that used the protocol spec from MySQL for inclusion in >> Phobos. Not sure where it stands. >> >> -Steve > > I wrote a reply yesterday that obviously didn't make it. > Sönke Ludwig integrated Steve Teales native mysql library: > https://github.com/rejectedsoftware/mysql-native Haven't had the time to > test it yet, but at least it compiles and is able to get metadata from > mysql. Actually, it looks like the vibe folks are using my fork of Steve Teales mysqln. I had hoped to contact Steve first, so that these changes existed in one place. https://github.com/JollieRoger All of the changes exist in individual branches off the master branch. Git will merge these into one file fuzzily. What they are is as follows: seperatemain - split main() into its own file (app.d in vibe). seperatemainwithport - main() using branch addporttoconnection. addporttoconnection - add no standard port selection to Connection. fixfordmd2058 - cosmetic changes to work with dmd-2.058. fixresultset - allow the return of an empty resultset. When iterating schema, test had no tables and would crash. fixconnection - would only connect to localhost in Steve's code. I have other changes that I haven't pushed up yet relating to NUMERIC and null variants with a more detailed main.d. Vibe.d looks interesting, I hope these fixes help.
is there a difference between those two notations
reduce!((int a, int b){return a+b;})(iota(100)) reduce!("a+b")(iota(100)) thanks in advance christian koestlin
Re: mysql binding/wrapper?
On Mon, 30 Apr 2012 16:08:34 +0200, Steven Schveighoffer wrote: On Sat, 28 Apr 2012 13:42:41 -0400, Adam D. Ruppe wrote: On Saturday, 28 April 2012 at 16:19:37 UTC, simendsjo wrote: Would you mind if the module was added to vibe, and thus relicensed to MIT? No idea if the vibe folks would actually want that though :) My stuff is all free to take as far as I'm concerned, but since this uses libmysql it might technically be GPL. If that's the case, using this lib will make your entire project GPL. I think the britseyeview version was an attempt by Steve Teale to write a non-GPL lib that used the protocol spec from MySQL for inclusion in Phobos. Not sure where it stands. -Steve I wrote a reply yesterday that obviously didn't make it. Sönke Ludwig integrated Steve Teales native mysql library: https://github.com/rejectedsoftware/mysql-native Haven't had the time to test it yet, but at least it compiles and is able to get metadata from mysql.
Re: mysql binding/wrapper?
On Sat, 28 Apr 2012 13:42:41 -0400, Adam D. Ruppe wrote: On Saturday, 28 April 2012 at 16:19:37 UTC, simendsjo wrote: Would you mind if the module was added to vibe, and thus relicensed to MIT? No idea if the vibe folks would actually want that though :) My stuff is all free to take as far as I'm concerned, but since this uses libmysql it might technically be GPL. If that's the case, using this lib will make your entire project GPL. I think the britseyeview version was an attempt by Steve Teale to write a non-GPL lib that used the protocol spec from MySQL for inclusion in Phobos. Not sure where it stands. -Steve
Re: Passing array as const slows down code?
On Fri, 27 Apr 2012 20:03:48 -0400, Joseph Rushton Wakeling wrote: On 28/04/12 00:29, Era Scarecrow wrote: Last try adding ref after const; At the off chance it's shallow copying, this should remove that. Ahhh, that works. Thank you! Back story: originally the reputation() function just took the array ratings and made an internal copy, ratings_, which was used by the rest of the code. I took that out in this commit: https://github.com/WebDrake/Dregs/commit/4d2a8a055321c2981a453fc4d82fb781da2ea5c7 ... because I found I got about a 2s speedup. It's exactly the speedup which was removed by adding "const" to the function input, so I presume it's as you say, that this was implicitly creating a local copy. Try removing the ref and see if it goes back. That usage of ref should not affect anything (if anything it should be slower, since it's an extra level of indirection). There is no implicit local copy for const. I have a suspicion that you changed two things and forgot about one of them when running your tests. -Steve
Compute in one pass 3 tokens position
Hi, I would like to know how compute in on pass 3 tokens position in a sequence. curently i do: File f = File( "reader.d", "r" ); scope(exit) f.close(); char[1024] buffer; char[] content = f.rawRead(buffer); char[sizediff_t] token = ['(', '{', ';']; auto position = map!( a => content.countUntil( a ) )( [ ['('], ['{'], [';'] ] ); if i use reduce instead map the build fail
Re: struct to/from void, object to/from void
On 04/30/2012 03:01 AM, Era Scarecrow wrote: On Monday, 30 April 2012 at 00:28:15 UTC, Jason King wrote: myobject.sizeof returns 4 (in 32 bit DMD) for every object I've tested, so I'm inclined to suspect its a bog-standard pointer, just what I'm looking to save and retrieve. Anybody else want to chime in? I'd say that's right and wrong. Someone correct me if I'm wrong. The 4(bytes) is likely the fat pointer of the string. It still has to contain information saying it's this type of object, and inheritance if it was of another type. I believe it will be something like you have a 16 byte header specifying the object(s) information, and then the object data (4 bytes in this case). This is where it differs from C++ and acts more like java. A heavy part of why this is the case is not only for casting up and down, but management of virtual functions (overloaded). Otherwise you get into C++'s old mess of needing to explicitly saying virtual for every function that 'MIGHT' be overloaded in the future. I haven't tested this, but you should get the idea. I have ;) class A {} class BA : A{} //returns a BA object from it's A superclass A test() { return cast(A) new BA(); //cast down } void test2() { A a = test(); BA ba = cast(BA) a; //fails if we have no information, we only see class A. Works because a was originally created as an BA we can cast is back to an BA. assert(ba !is null, "Failed! ba not inherited from A?"); } -- Mike Wey
Re: type conversions
On 4/30/12 8:08 AM, Jonathan M Davis wrote: On Monday, April 30, 2012 01:42:38 WhatMeWorry wrote: I'm trying to get my head around D's type conversion. What is the best way to convert a string to a char array? Or I should say is this the best way? string s = "Hello There"; char[] c; c = string.dup; dup will return a mutable copy of an array. idup will return an immutable copy of an array. They will both always copy. If you want to convert without having to make a copy if the array is of the constancy that you want already (e.g. if a templated function is templated on string type, and it could be any constancy of char[]), then use std.conv.to. auto c = to!(char[])(str); If str was already char[], then it will just be returned, whereas if it's immutable(char)[], then it would dup it and return that. Also, what is the best way to explicitly convert a string to an int? I've been looking at Library Reference (Phobos) but I'm stuck. Use std.conv.to: auto i = to!string("1234"); std.conv.to is what you use for pretty much any conversion. - Jonathan M Davis Can the documentation of std.conv be fixed? http://dlang.org/phobos/std_conv.html#to I mean, all the toImpl methods are documented, but in "to" it clearly says "Client code normally calls to!TargetType(value) (and not some variant of toImpl." I think all the documentation should be in "to". Now it sounds like you know what "to" does... but people read documentation because they don't know what it does. There's also no need to document all the different parse methods in different places. Just one place is enough and simpler to read.