Re: Why is sort allocating in this case?

2015-09-17 Thread Jack Stouffer via Digitalmars-d-learn
On Friday, 18 September 2015 at 02:29:55 UTC, Jack Stouffer wrote: On Friday, 18 September 2015 at 02:24:44 UTC, Adam D. Ruppe wrote: Works for me. What version are you using? Might be the old one wasn't actually marked nogc yet. I'm using the git head, must be a regression. Well apparently

Re: Why is sort allocating in this case?

2015-09-17 Thread Jack Stouffer via Digitalmars-d-learn
On Friday, 18 September 2015 at 02:24:44 UTC, Adam D. Ruppe wrote: Works for me. What version are you using? Might be the old one wasn't actually marked nogc yet. I'm using the git head, must be a regression.

Re: Why is sort allocating in this case?

2015-09-17 Thread Adam D. Ruppe via Digitalmars-d-learn
Works for me. What version are you using? Might be the old one wasn't actually marked nogc yet.

Why is sort allocating in this case?

2015-09-17 Thread Jack Stouffer via Digitalmars-d-learn
The docs explicitly say that SwapStrategy.unstable is non-allocating, but this code (which is for finding the statistical mode of a range) will fail to compile. auto mode(alias pred = "a == b", R)(R r) @nogc if (is(ElementType!R : real) && isInputRange!R && !isInfinite!R) {

Re: Passing Arguments on in Variadic Functions

2015-09-17 Thread anonymous via Digitalmars-d-learn
On Thursday 17 September 2015 23:27, jmh530 wrote: > I think I could figure out how to look through the arguments for > a bool, but wouldn't that make me give up the default value for > the bool? If you don't find a bool, you use the default value.

Re: Anybody use Derelict FreeType recently (successfully)

2015-09-17 Thread BBasile via Digitalmars-d-learn
On Thursday, 17 September 2015 at 22:22:22 UTC, WhatMeWorry wrote: [...] After hours of reading existing freetype/derelict documents, I'm stuck again. Any suggestions. Thanks. Hello, this[1] compiled dll one works fine here on windows: - inside this folder: https://github.com/buggins/dlangui

Re: Anybody use Derelict FreeType recently (successfully)

2015-09-17 Thread WhatMeWorry via Digitalmars-d-learn
On Thursday, 17 September 2015 at 05:27:08 UTC, Mike Parker wrote: On Thursday, 17 September 2015 at 04:58:05 UTC, WhatMeWorry wrote: Compiling and linking was error free, but when I hit DerelictFT.load(); my program aborts with the following run time message: derelict.util.exception.SymbolL

Re: Passing Arguments on in Variadic Functions

2015-09-17 Thread jmh530 via Digitalmars-d-learn
On Thursday, 17 September 2015 at 21:27:31 UTC, jmh530 wrote: There's probably a way to clean this up better, but this is what I was talking about. import std.algorithm : sum; import std.stdio : writeln; import std.traits : isNumeric; auto test(T)(T x, bool sample=true) { auto sum_

Re: Passing Arguments on in Variadic Functions

2015-09-17 Thread jmh530 via Digitalmars-d-learn
On Thursday, 17 September 2015 at 18:40:56 UTC, Adam D. Ruppe wrote: I would actually just make it required or do separate functions with it. Optional and variadics don't mix well together. (You could also loop through and look for a bool argument yourself but that is a bit messier.) It'

Re: mysql-native: SQL Transaction support?

2015-09-17 Thread Gary Willoughby via Digitalmars-d-learn
On Thursday, 17 September 2015 at 19:47:33 UTC, salvari wrote: I'm parsing a text input file, the generated sql is about 1 million lines of SQL. By using mysql-native it takes about 4 hours to load data. I've used mysql-native before to handle hundreds of millions of rows of data and I rememb

Re: Passing Arguments on in Variadic Functions

2015-09-17 Thread jmh530 via Digitalmars-d-learn
On Thursday, 17 September 2015 at 18:40:56 UTC, Adam D. Ruppe wrote: import std.meta; import std.traits; if(allSatisfy!(isNumeric, V)) should do it Was not aware of allSatisfy. Thanks.

Re: Template Oriented Programming

2015-09-17 Thread Justin Whear via Digitalmars-d-learn
On Thu, 17 Sep 2015 20:41:11 +, Adam wrote: > Is this the basic idea? > > Use templates when you want more power? That is, TOP can do everything > OOP can do but more? Or are these ultimately two orthogonal concepts? I think you've got the right idea. Some unordered thoughts: * OOP provide

Template Oriented Programming

2015-09-17 Thread Adam via Digitalmars-d-learn
I'm not sure if "Template Oriented Programming" seems to be the way to go in D, but I've got my head mainly stuck around OOP. I'm a bit confused about how to dive into it. With OOP, we create interfaces, which provide a contract that all implementers of the interface have to abide by. Delegati

Re: bug? for(int i=0;i<1;) vs while(true)

2015-09-17 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 17 September 2015 at 19:47:15 UTC, ddos wrote: yeah i tried for(;;) and it generates the same warning :) sure, here is the full example, it's not too long anyways ( the example doesn't make much sense tho because socket.accept is blocking :P ) http://pastebin.com/9K0wRRD6 Yeah, i

Re: bug? for(int i=0;i<1;) vs while(true)

2015-09-17 Thread Timon Gehr via Digitalmars-d-learn
On 09/17/2015 09:47 PM, ddos wrote: yeah i tried for(;;) and it generates the same warning :) sure, here is the full example, it's not too long anyways ( the example doesn't make much sense tho because socket.accept is blocking :P ) http://pastebin.com/9K0wRRD6 ps: pastebin needs D support :-D

mysql-native: SQL Transaction support?

2015-09-17 Thread salvari via Digitalmars-d-learn
I'm using mysql-native library for massive data load. I've been trying to use transactions to improve performance but it doesn't seem to work. I'm parsing a text input file, the generated sql is about 1 million lines of SQL. By using mysql-native it takes about 4 hours to load data. I've tr

Re: bug? for(int i=0;i<1;) vs while(true)

2015-09-17 Thread ddos via Digitalmars-d-learn
On Thursday, 17 September 2015 at 19:43:02 UTC, H. S. Teoh wrote: On Thu, Sep 17, 2015 at 07:32:13PM +, ddos via Digitalmars-d-learn wrote: http://pastebin.com/fknwgjtz i tried to call fibers in a loop forever, to multiplex some networking client worker fibers and a listener fiber it seem

Re: How not to run after a DUB build ?

2015-09-17 Thread BBasile via Digitalmars-d-learn
On Thursday, 17 September 2015 at 19:36:10 UTC, BBasile wrote: Each time I execute `dub.exe --build=release` (or any other the build type) DUB tries to run the project after the build. This generates often generates an error when dub process returns (and even if the build is OK) but actually

Re: bug? for(int i=0;i<1;) vs while(true)

2015-09-17 Thread ddos via Digitalmars-d-learn
On Thursday, 17 September 2015 at 19:35:05 UTC, Adam D. Ruppe wrote: What's there? Anything after an endless loop is potentially unreachable and dub treats warnings as errors. i see, thx

Re: bug? for(int i=0;i<1;) vs while(true)

2015-09-17 Thread H. S. Teoh via Digitalmars-d-learn
On Thu, Sep 17, 2015 at 07:32:13PM +, ddos via Digitalmars-d-learn wrote: > http://pastebin.com/fknwgjtz > > i tried to call fibers in a loop forever, to multiplex some networking > client worker fibers and a listener fiber > it seems to work correctly with for(int i=0;i<1;) > > with while(t

Re: bug? for(int i=0;i<1;) vs while(true)

2015-09-17 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 17 September 2015 at 19:32:16 UTC, ddos wrote: source\app.d(72): Warning: statement is not reachable What's there? Anything after an endless loop is potentially unreachable and dub treats warnings as errors. With the for loop, the compiler can't be as sure that it is endless be

How not to run after a DUB build ?

2015-09-17 Thread BBasile via Digitalmars-d-learn
Each time I execute `dub.exe --build=release` (or any other the build type) DUB tries to run the project after the build. This generates often generates an error when dub process returns (and even if the build is OK) but actually I don't want DUB to run after building. Is there a switch to av

Re: bug? for(int i=0;i<1;) vs while(true)

2015-09-17 Thread ddos via Digitalmars-d-learn
using DMD32 D Compiler v2.068.0 on windows x64

bug? for(int i=0;i<1;) vs while(true)

2015-09-17 Thread ddos via Digitalmars-d-learn
http://pastebin.com/fknwgjtz i tried to call fibers in a loop forever, to multiplex some networking client worker fibers and a listener fiber it seems to work correctly with for(int i=0;i<1;) with while(true) i get: C:\dev\server_client>dub Building server_client ~master configuration "appli

Re: Passing Arguments on in Variadic Functions

2015-09-17 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 17 September 2015 at 17:35:18 UTC, jmh530 wrote: I noticed that there's some interesting interplay with this technique and default arguments. Yeah, it expects the V... to consume the rest of the arguments so it doesn't really leave any room for the default arg. I would actually

Re: Creating a DLL with a ActiveX interface.

2015-09-17 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 17 September 2015 at 17:58:49 UTC, Taylor Hillegeist wrote: if anyone knows how to easily convert between the two i would be happy to know. You'll just need to write an adapter... I started a minimal one here: https://github.com/adamdruppe/com/blob/master/comhelpers.d#L123 but

Re: Load Qt UI XML File as GUI

2015-09-17 Thread michaelc37 via Digitalmars-d-learn
On Wednesday, 16 September 2015 at 04:03:46 UTC, Mike McKee wrote: Unfortunately, the http://dsource.org/forums/ doesn't appear to be active -- I can't login after I registered. This is where the QtD project has their forum. So, I'm asking this here. Is it possible with D and QtD to draw my GU

Re: Creating a DLL with a ActiveX interface.

2015-09-17 Thread Taylor Hillegeist via Digitalmars-d-learn
On Wednesday, 16 September 2015 at 16:08:47 UTC, Taylor Hillegeist wrote: export extern (Windows) void SayHello(Variant *Input_Variant) { string A = "HELLO WORLD!"; Input_Variant.CA_VariantSetCString(A.ptr); } So I made a terrible error. Looking at http://lunesu.com/uploads/Modern

Re: Passing Arguments on in Variadic Functions

2015-09-17 Thread jmh530 via Digitalmars-d-learn
On Monday, 14 September 2015 at 20:26:56 UTC, jmh530 wrote: Thanks to you both. This works perfect. I noticed that there's some interesting interplay with this technique and default arguments. From below, it is required that you put the ones with default arguments last. If there are only tw

Re: Pretty Printing TickDuration

2015-09-17 Thread Nordlöw via Digitalmars-d-learn
On Thursday, 17 September 2015 at 16:54:02 UTC, Nordlöw wrote: How do I convert an instance of `TickDuration` to that format? Solution: writeln("> Query took ", sw.peek().to!Duration);

Pretty Printing TickDuration

2015-09-17 Thread Nordlöw via Digitalmars-d-learn
Currently import std.datetime: StopWatch; StopWatch sw; sw.start; writeln(sw.peek()); prints for instance TickDuration(279483) I've seen Phobos doing something much more clever such as pretty printing of time in the format: 1 hour, 2 seconds, 3 milliseconds, etc. How do

Re: Bloat with std.(string.)format?

2015-09-17 Thread Chris via Digitalmars-d-learn
On Thursday, 17 September 2015 at 15:17:21 UTC, John Colvin wrote: On Thursday, 17 September 2015 at 13:42:15 UTC, Chris wrote: On Thursday, 17 September 2015 at 12:49:03 UTC, John Colvin wrote: [...] Thanks. That's up to date enough now. Is it stable, though? Reasonably so in my testing,

Re: Defining compile-time constants?

2015-09-17 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 17 September 2015 at 15:32:25 UTC, Tim K. wrote: I am wondering if there is any way to define constants to pass to the compiler like in C (especially useful in combination with Makefiles, for obvious reasons), i.e.: My preference is to make an app.config module that lists these t

Re: Defining compile-time constants?

2015-09-17 Thread Rikki Cattermole via Digitalmars-d-learn
On 18/09/15 3:32 AM, Tim K. wrote: Hi! I am wondering if there is any way to define constants to pass to the compiler like in C (especially useful in combination with Makefiles, for obvious reasons), i.e.: gcc -DPREFIX=\"/usr/local\" -o myprogram main.c Like this a program can look for ce

Defining compile-time constants?

2015-09-17 Thread Tim K. via Digitalmars-d-learn
Hi! I am wondering if there is any way to define constants to pass to the compiler like in C (especially useful in combination with Makefiles, for obvious reasons), i.e.: gcc -DPREFIX=\"/usr/local\" -o myprogram main.c Like this a program can look for certain files inside its prefix dur

Re: Load Qt UI XML File as GUI

2015-09-17 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/16/15 3:08 PM, Ali Çehreli wrote: On 09/15/2015 09:36 PM, Steven Schveighoffer wrote: On 9/16/15 12:03 AM, Mike McKee wrote: Unfortunately, the http://dsource.org/forums/ doesn't appear to be active -- I can't login after I registered. This is where the QtD project has their forum. So, I'm

Re: Bloat with std.(string.)format?

2015-09-17 Thread John Colvin via Digitalmars-d-learn
On Thursday, 17 September 2015 at 13:42:15 UTC, Chris wrote: On Thursday, 17 September 2015 at 12:49:03 UTC, John Colvin wrote: [...] Thanks. That's up to date enough now. Is it stable, though? Reasonably so in my testing, but expect more bugs than in a full release. For version 2.067.1

Re: Why do abstract class functions require definitions?

2015-09-17 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/16/15 6:36 AM, Marc Schütz wrote: Wouldn't the following behaviour be more useful as a default? abstract class Foo { void bar1() { } // non-abstract, obviously void bar2();// abstract, because it's in an abstract class // (dif

Re: Bloat with std.(string.)format?

2015-09-17 Thread Chris via Digitalmars-d-learn
On Thursday, 17 September 2015 at 12:49:03 UTC, John Colvin wrote: On Thursday, 17 September 2015 at 10:53:17 UTC, Chris wrote: On Thursday, 17 September 2015 at 10:33:44 UTC, John Colvin wrote: Some initial bloat is expected, format is pretty big (although twice as big is a lot, unless your

Re: Reading Atributes (UDA) of overloaded functions

2015-09-17 Thread John Colvin via Digitalmars-d-learn
On Thursday, 17 September 2015 at 12:40:24 UTC, Ozan wrote: On Thursday, 17 September 2015 at 12:36:42 UTC, John Colvin wrote: On Thursday, 17 September 2015 at 11:47:40 UTC, Ozan wrote: ... use __traits(getAttributes, /*...*/) on each of the members of the result of __traits(getOverloads, /*.

Re: Bloat with std.(string.)format?

2015-09-17 Thread John Colvin via Digitalmars-d-learn
On Thursday, 17 September 2015 at 10:53:17 UTC, Chris wrote: On Thursday, 17 September 2015 at 10:33:44 UTC, John Colvin wrote: Some initial bloat is expected, format is pretty big (although twice as big is a lot, unless your original code was quite small?). It was in a test program. Only a

Re: Reading Atributes (UDA) of overloaded functions

2015-09-17 Thread Ozan via Digitalmars-d-learn
On Thursday, 17 September 2015 at 12:36:42 UTC, John Colvin wrote: On Thursday, 17 September 2015 at 11:47:40 UTC, Ozan wrote: ... use __traits(getAttributes, /*...*/) on each of the members of the result of __traits(getOverloads, /*...*/) Great! Thanks! Now it works: foreach (ov; __

Re: Reading Atributes (UDA) of overloaded functions

2015-09-17 Thread John Colvin via Digitalmars-d-learn
On Thursday, 17 September 2015 at 11:47:40 UTC, Ozan wrote: Hi! Is it possible to read all attributes in case of overloading functions? Example: struct Att { string name; } struct Att2 { string name; } @Att void testUDA(string x) { writeln("test(string ",x,")"); } @Att2 void testUDA(int x) {

Re: Runtime error when calling a callback in a parallel Task

2015-09-17 Thread Kagamin via Digitalmars-d-learn
Maybe compiler generates wrong code, try to debug at instruction level.

Reading Atributes (UDA) of overloaded functions

2015-09-17 Thread Ozan via Digitalmars-d-learn
Hi! Is it possible to read all attributes in case of overloading functions? Example: struct Att { string name; } struct Att2 { string name; } @Att void testUDA(string x) { writeln("test(string ",x,")"); } @Att2 void testUDA(int x) { writeln("test(string ",x,")"); } void main(string[] args) {

Re: Thrift

2015-09-17 Thread Nikolay via Digitalmars-d-learn
On Wednesday, 16 September 2015 at 16:57:39 UTC, ddos wrote: please help if you know how to get a simple example with d & thrift running thx, dominik Some time ago I could use facebook brunch with dlang: https://github.com/facebook/fbthrift

Re: Bloat with std.(string.)format?

2015-09-17 Thread Chris via Digitalmars-d-learn
On Thursday, 17 September 2015 at 10:33:44 UTC, John Colvin wrote: Some initial bloat is expected, format is pretty big (although twice as big is a lot, unless your original code was quite small?). It was in a test program. Only a few lines. But it would still add a lot of bloat in a progra

Re: Bloat with std.(string.)format?

2015-09-17 Thread John Colvin via Digitalmars-d-learn
On Thursday, 17 September 2015 at 09:54:07 UTC, Chris wrote: If I have code like this: auto builder = appender!string; builder ~= "Hello, World!"; builder ~= "I'm here!"; builder ~= "Now I'm there!"; the object file grows by 10-11 lines with each call to `builder ~=`. If I use this: builder

Bloat with std.(string.)format?

2015-09-17 Thread Chris via Digitalmars-d-learn
If I have code like this: auto builder = appender!string; builder ~= "Hello, World!"; builder ~= "I'm here!"; builder ~= "Now I'm there!"; the object file grows by 10-11 lines with each call to `builder ~=`. If I use this: builder ~= format("%s", "Hello, World!"); builder ~= format("%s", "I'm