Re: Strange exception, with EXTREMELY SIMPLE toString() in a struct

2015-12-07 Thread rumbu via Digitalmars-d-learn
On Monday, 7 December 2015 at 08:17:27 UTC, Enjoys Math wrote: Exception Message: First-chance exception: std.format.FormatException Unterminated format specifier: "%" at C:\D\dmd2\windows\bin\..\..\src\phobos\std\format.d(828) [CODE] module set; import std.conv; struct Set(T) {

Re: Do a class invariants affect -release builds?

2015-12-07 Thread Steven Schveighoffer via Digitalmars-d-learn
On 12/6/15 6:01 PM, Andrew LaChance wrote: On Saturday, 5 December 2015 at 23:27:31 UTC, Steven Schveighoffer wrote: On 12/5/15 6:06 PM, Andrew LaChance wrote: I was reading a blog post here: http://3d.benjamin-thaut.de/?p=20 which mentions: "Calls to the druntime invariant handler are

Re: Comparison operator overloading

2015-12-07 Thread Mike Parker via Digitalmars-d-learn
On Monday, 7 December 2015 at 11:49:51 UTC, Dominikus Dittes Scherkl wrote: On Sunday, 6 December 2015 at 15:01:08 UTC, cym13 wrote: Don't use opCmp, all binary operators should be overriden using opBinary. For more information I recommend this page

Question about mysql-d Object

2015-12-07 Thread Martin Tschierschke via Digitalmars-d-learn
When I do the following: auto mysql = new Mysql("localhost", 3306, "mt", "", "verwaltung"); auto rows = mysql.query("select field from my_table limit 50"); foreach(row;rows){ writeln(row["field"]);} // second time same loop foreach(row;rows){ writeln(row["field"]);} I only get the output

Re: Question about mysql-d Object

2015-12-07 Thread Daniel Kozak via Digitalmars-d-learn
On Monday, 7 December 2015 at 14:40:12 UTC, Martin Tschierschke wrote: When I do the following: auto mysql = new Mysql("localhost", 3306, "mt", "", "verwaltung"); auto rows = mysql.query("select field from my_table limit 50"); foreach(row;rows){ writeln(row["field"]);} // second time same

Re: Comparison operator overloading

2015-12-07 Thread Dominikus Dittes Scherkl via Digitalmars-d-learn
On Monday, 7 December 2015 at 13:31:52 UTC, Mike Parker wrote: On Monday, 7 December 2015 at 11:49:51 UTC, Dominikus Dittes Scherkl wrote: On the other hand the chapter also states that opCmp() should always return "int" - which is a bad idea if you e.g. want to provide a "NaN" value in your

Re: Pixelbuffer to draw on a surface

2015-12-07 Thread TheDGuy via Digitalmars-d-learn
On Sunday, 6 December 2015 at 13:32:19 UTC, visitor wrote: gtkd demos for examples, might be of interest, like clock : https://github.com/gtkd-developers/GtkD/blob/master/demos/cairo/cairo_clock/clock.d Thanks! I didn't knew about that source, that helped me alot :)

Re: Question about mysql-d Object

2015-12-07 Thread Márcio Martins via Digitalmars-d-learn
On Monday, 7 December 2015 at 14:40:12 UTC, Martin Tschierschke wrote: When I do the following: auto mysql = new Mysql("localhost", 3306, "mt", "", "verwaltung"); auto rows = mysql.query("select field from my_table limit 50"); foreach(row;rows){ writeln(row["field"]);} // second time same

Strange exception, with EXTREMELY SIMPLE toString() in a struct

2015-12-07 Thread Enjoys Math via Digitalmars-d-learn
Exception Message: First-chance exception: std.format.FormatException Unterminated format specifier: "%" at C:\D\dmd2\windows\bin\..\..\src\phobos\std\format.d(828) [CODE] module set; import std.conv; struct Set(T) { string toString() const { auto str = "{";

Re: Strange exception, with EXTREMELY SIMPLE toString() in a struct

2015-12-07 Thread Marc Schütz via Digitalmars-d-learn
On Monday, 7 December 2015 at 08:17:27 UTC, Enjoys Math wrote: Exception Message: First-chance exception: std.format.FormatException Unterminated format specifier: "%" at C:\D\dmd2\windows\bin\..\..\src\phobos\std\format.d(828) [CODE] module set; import std.conv; struct Set(T) {

Re: benchmark on binary trees

2015-12-07 Thread Alex via Digitalmars-d-learn
On Sunday, 6 December 2015 at 12:23:52 UTC, visitor wrote: Hello, interesting exercise for me to learn about allocators :-) Nice to know, a novice can inspire someone :) i managed to parallelize the code reaching similar performance, in terms of speed, as the non parallel version :

Re: Strange exception, with EXTREMELY SIMPLE toString() in a struct

2015-12-07 Thread Radu via Digitalmars-d-learn
On Monday, 7 December 2015 at 08:17:27 UTC, Enjoys Math wrote: Exception Message: First-chance exception: std.format.FormatException Unterminated format specifier: "%" at C:\D\dmd2\windows\bin\..\..\src\phobos\std\format.d(828) [CODE] module set; import std.conv; struct Set(T) {

Re: benchmark on binary trees

2015-12-07 Thread Alex via Digitalmars-d-learn
On Sunday, 6 December 2015 at 08:45:10 UTC, Rikki Cattermole wrote: Why is TreeNode not final? This is an interesting hint! Just after adding final the program takes two seconds less... This is roughly 5%. Do you have another hints of this kind? ;) Also yours does not use threads in any

Re: Comparison operator overloading

2015-12-07 Thread Dominikus Dittes Scherkl via Digitalmars-d-learn
On Sunday, 6 December 2015 at 15:01:08 UTC, cym13 wrote: Don't use opCmp, all binary operators should be overriden using opBinary. For more information I recommend this page http://ddili.org/ders/d.en/operator_overloading.html Why should we don't use opCmp() ? I can't see any recommendation

Re: Comparison operator overloading

2015-12-07 Thread Márcio Martins via Digitalmars-d-learn
On Monday, 7 December 2015 at 00:43:50 UTC, Ali Çehreli wrote: On 12/06/2015 06:41 AM, Márcio Martins wrote: > auto m = (a > b) * a + 15; > auto c = a.choose(a > b)^^2; What do those operations do? Are you thinking of a special meaning for '>', perhaps common in numerical computations, which

AA struct hashing bug?

2015-12-07 Thread Random D user via Digitalmars-d-learn
struct Foo { this( int k ) { a = k; } int a; } Foo foo; int[ Foo ] map; map[ foo ] = 1; // Crash! bug? // This also crashes. I believe crash above makes a call like this (or similar) in the rt. //auto h = typeid( foo ).getHash( ); // Crash! win64 & dmd 2.69.2

How to make a transparent wrapper type?

2015-12-07 Thread Random D user via Digitalmars-d-learn
I kind of miss reference values on stack, so I attempted to make one in a struct. Pointers are pretty good (since d doesn't have ->), but it would be nice to avoid dereferencing them explicitly on assignment. Since reference is a pointer that you can't change afterwards. I tried something like

Re: benchmark on binary trees

2015-12-07 Thread visitor via Digitalmars-d-learn
On Monday, 7 December 2015 at 10:55:25 UTC, Alex wrote: On Sunday, 6 December 2015 at 12:23:52 UTC, visitor wrote: Hello, interesting exercise for me to learn about allocators :-) Nice to know, a novice can inspire someone :) i managed to parallelize the code reaching similar performance, in

Re: How to make a transparent wrapper type?

2015-12-07 Thread Namespace via Digitalmars-d-learn
This seems to work: struct RefVal(T) { private T* ptr; this(T* val) { ptr = val; } ref auto opAssign(U)(auto ref U value) { *ptr = value; return *ptr; } auto

The @@@BUG@@@ the size of China - std.conv.d - Target parse(Target, Source)(ref Source s, uint radix)

2015-12-07 Thread John Carter via Digitalmars-d-learn
So whilst attempt to convert from a hex string (without the 0x) to int I bumped into the @@@BUG@@@ the size of China https://github.com/D-Programming-Language/phobos/blob/master/std/conv.d#L2270 Is there a bugzilla issue number tracking this? Searching for conv and parse in the issue

How do you create an opengl window with DerelictOrg?

2015-12-07 Thread Enjoys Math via Digitalmars-d-learn
I've seen these: https://github.com/DerelictOrg?page=1 BUt not sure how to use them, examples?

Re: How do you create an opengl window with DerelictOrg?

2015-12-07 Thread Alex Parrill via Digitalmars-d-learn
On Monday, 7 December 2015 at 21:33:57 UTC, Enjoys Math wrote: I've seen these: https://github.com/DerelictOrg?page=1 BUt not sure how to use them, examples? Derelict is just bindings for other libraries, for using C libraries with D. Pick a library that does windows management (I use GLFW,

Re: How do you create an opengl window with DerelictOrg?

2015-12-07 Thread BLM768 via Digitalmars-d-learn
On Monday, 7 December 2015 at 21:33:57 UTC, Enjoys Math wrote: I've seen these: https://github.com/DerelictOrg?page=1 BUt not sure how to use them, examples? OpenGL itself can't create a window/context, so you'll need to use DerelictGLFW or DerelictSDL. GLFW is lighter-weight. Combine the

Re: AA struct hashing bug?

2015-12-07 Thread Alex Parrill via Digitalmars-d-learn
On Monday, 7 December 2015 at 18:48:18 UTC, Random D user wrote: struct Foo { this( int k ) { a = k; } int a; } Foo foo; int[ Foo ] map; map[ foo ] = 1; // Crash! bug? // This also crashes. I believe crash above makes a call like this (or similar) in the rt. //auto

Re: How do you create an opengl window with DerelictOrg?

2015-12-07 Thread Enjoys Math via Digitalmars-d-learn
On Monday, 7 December 2015 at 22:01:15 UTC, BLM768 wrote: On Monday, 7 December 2015 at 21:33:57 UTC, Enjoys Math wrote: I've seen these: https://github.com/DerelictOrg?page=1 BUt not sure how to use them, examples? OpenGL itself can't create a window/context, so you'll need to use

Re: How do you create an opengl window with DerelictOrg?

2015-12-07 Thread Guillaume Piolat via Digitalmars-d-learn
On Monday, 7 December 2015 at 22:19:17 UTC, Enjoys Math wrote: On Monday, 7 December 2015 at 22:01:15 UTC, BLM768 wrote: On Monday, 7 December 2015 at 21:33:57 UTC, Enjoys Math wrote: I've seen these: https://github.com/DerelictOrg?page=1 BUt not sure how to use them, examples? OpenGL

Re: The @@@BUG@@@ the size of China - std.conv.d - Target parse(Target, Source)(ref Source s, uint radix)

2015-12-07 Thread anonymous via Digitalmars-d-learn
On 07.12.2015 21:56, John Carter wrote: So whilst attempt to convert from a hex string (without the 0x) to int I bumped into the @@@BUG@@@ the size of China https://github.com/D-Programming-Language/phobos/blob/master/std/conv.d#L2270 Is there a bugzilla issue number tracking this?

Re: The @@@BUG@@@ the size of China - std.conv.d - Target parse(Target, Source)(ref Source s, uint radix)

2015-12-07 Thread Steven Schveighoffer via Digitalmars-d-learn
On 12/7/15 5:32 PM, anonymous wrote: On 07.12.2015 21:56, John Carter wrote: So whilst attempt to convert from a hex string (without the 0x) to int I bumped into the @@@BUG@@@ the size of China https://github.com/D-Programming-Language/phobos/blob/master/std/conv.d#L2270 Is there a

Re: Comparison operator overloading

2015-12-07 Thread Anonymous via Digitalmars-d-learn
On Monday, 7 December 2015 at 17:18:20 UTC, Dominikus Dittes Scherkl wrote: Hmm. But it works just fine! It overloads also the special floatingpoint operators <> !<> !<= and so on. Those are deprecated: http://dlang.org/deprecate.html#Floating%20point%20NCEG%20operators And how else could I

Re: AA struct hashing bug?

2015-12-07 Thread ketmar via Digitalmars-d-learn
worksforme. git HEAD, GNU/Linux, x86.

Re: Reset all Members of a Aggregate Instance

2015-12-07 Thread Daniel Murphy via Digitalmars-d-learn
On 4/12/2015 8:38 AM, Chris Wright wrote: An object reference is just a pointer, but we can't directly cast it. So we make a pointer to it and cast that; the type system allows it. Now we can access the data that the object reference refers to directly. Casting is fine too: cast(void*)classRef

Re: The @@@BUG@@@ the size of China - std.conv.d - Target parse(Target, Source)(ref Source s, uint radix)

2015-12-07 Thread tsbockman via Digitalmars-d-learn
On Monday, 7 December 2015 at 20:56:24 UTC, John Carter wrote: So whilst attempt to convert from a hex string (without the 0x) to int I bumped into the @@@BUG@@@ the size of China https://github.com/D-Programming-Language/phobos/blob/master/std/conv.d#L2270 Is there a bugzilla issue

Re: The @@@BUG@@@ the size of China - std.conv.d - Target parse(Target, Source)(ref Source s, uint radix)

2015-12-07 Thread tsbockman via Digitalmars-d-learn
On Monday, 7 December 2015 at 22:38:03 UTC, Steven Schveighoffer wrote: It's an old bug, if it still exists. But in any case, the description is terrible. A real bug report should be filed. -Steve Filed (https://issues.dlang.org/show_bug.cgi?id=15419) and fixed

Re: AA struct hashing bug?

2015-12-07 Thread Ivan Kazmenko via Digitalmars-d-learn
On Monday, 7 December 2015 at 22:03:42 UTC, Alex Parrill wrote: On Monday, 7 December 2015 at 18:48:18 UTC, Random D user wrote: struct Foo { this( int k ) { a = k; } int a; } Foo foo; int[ Foo ] map; map[ foo ] = 1; // Crash! bug? // This also crashes. I believe

Re: Reset all Members of a Aggregate Instance

2015-12-07 Thread Chris Wright via Digitalmars-d-learn
On Tue, 08 Dec 2015 14:12:02 +1100, Daniel Murphy wrote: > On 4/12/2015 8:38 AM, Chris Wright wrote: >> An object reference is just a pointer, but we can't directly cast it. >> So we make a pointer to it and cast that; the type system allows it. >> Now we can access the data that the object