Re: how to debug exceptions/asserts thrown in module constructors?

2016-11-27 Thread Basile B. via Digitalmars-d-learn
On Monday, 28 November 2016 at 02:52:02 UTC, Basile B. wrote: On Sunday, 27 November 2016 at 22:19:26 UTC, Timothee Cour wrote: Adding ``` b _d_throwc #does nothing ``` Don't ask me why I wouldn't be able to answer. The only thing that I can say is that it's probably related to one of the

Re: how to debug exceptions/asserts thrown in module constructors?

2016-11-27 Thread Basile B. via Digitalmars-d-learn
On Sunday, 27 November 2016 at 22:19:26 UTC, Timothee Cour wrote: Adding ``` b _d_throwc #does nothing ``` Try instead "b _d_throwdwarf". Changes made earlier this year to EH made _d_throwc obsolete. The equivalent is now _d_throwdwarf. Don't ask me why I wouldn't be able to answer.

Re: Using the result of a comma expression is deprecated

2016-11-27 Thread Mike Parker via Digitalmars-d-learn
On Sunday, 27 November 2016 at 16:32:26 UTC, Suliman wrote: Looks like you forgot a call to format before the opening parenthesis. should be: string sqlinsert = format(`INSERT INTO usersshapes (userlogin, uploading_date, geometry_type, data) VALUES ('%s', '%s', '%s', '%s') `, login,

Re: Creating array of structs being used in C interface

2016-11-27 Thread Adam D. Ruppe via Digitalmars-d-learn
On Sunday, 27 November 2016 at 23:25:57 UTC, Nicholas Wilson wrote: `_D10neo4jTypes17neo4j_map_entry_t6__initZ`, or Unions are supposed to be default initialised with the first member, a ulong and thus should be zero initialised. Right, but neo4j_map_entry_t is a struct and that's the one it

Re: Creating array of structs being used in C interface

2016-11-27 Thread Nicholas Wilson via Digitalmars-d-learn
On Sunday, 27 November 2016 at 13:54:54 UTC, Adam D. Ruppe wrote: On Sunday, 27 November 2016 at 12:59:32 UTC, Timoses wrote: [...] It is a linker problem because you didn't link to it... D structs have an initializer, even if they are used for interfacing with C. This is a small blob of

Re: how to debug exceptions/asserts thrown in module constructors?

2016-11-27 Thread timotheecour via Digitalmars-d-learn
UPDATE: * b Loader.d:123 didn't help either: error: parsing line table prologue at 0x (parsing ended around 0x Breakpoint 1: where = mybinary.temp`D4gtkc6Loader6Linker12_staticDtor3FZv, address = 0x000100315410 (process exited despite breakpoint); dmd's dwarf debug info

Re: how to debug exceptions/asserts thrown in module constructors?

2016-11-27 Thread Timothee Cour via Digitalmars-d-learn
UPDATE: * b Loader.d:123 didn't help either: error: parsing line table prologue at 0x (parsing ended around 0x Breakpoint 1: where = mybinary.temp`D4gtkc6Loader6Linker12_staticDtor3FZv, address = 0x000100315410 (process exited despite breakpoint); dmd's dwarf debug info seems

Re: non-constant expression ["foo":5, "bar":10, "baz":2000]

2016-11-27 Thread John Colvin via Digitalmars-d-learn
On Saturday, 26 November 2016 at 17:37:57 UTC, Paolo Invernizzi wrote: This is stated in documentation [1]: immutable long[string] aa = [ "foo": 5, "bar": 10, "baz": 2000 ]; unittest { assert(aa["foo"] == 5); assert(aa["bar"] == 10); assert(aa["baz"] == 2000); } But results

how to debug exceptions/asserts thrown in module constructors?

2016-11-27 Thread Timothee Cour via Digitalmars-d-learn
in the process of trying to debug https://github.com/BlackEdder/ggplotd/issues/32 I would like to get a stracktrace and/or put a breakpoint before exception is thrown: ``` lldb $binary r (lldb) Process 34168 resuming

Re: Parsing a string to instantiate classes at runtime

2016-11-27 Thread ag0aep6g via Digitalmars-d-learn
On 11/27/2016 10:19 PM, Marduk wrote: On Sunday, 27 November 2016 at 21:10:30 UTC, ag0aep6g wrote: Can you link that post, please? I can't imagine what "dynamic mixin" could refer to. Sure, it's here: http://forum.dlang.org/post/xmnnsdiuwyjrhkasy...@forum.dlang.org Ok, that's a

Re: non-constant expression ["foo":5, "bar":10, "baz":2000]

2016-11-27 Thread Paolo Invernizzi via Digitalmars-d-learn
On Saturday, 26 November 2016 at 19:57:21 UTC, Adam D. Ruppe wrote: On Saturday, 26 November 2016 at 17:37:57 UTC, Paolo Invernizzi wrote: This is stated in documentation [1]: What's the link? This is a known limitation, it has never worked. The docs should reflect that, though some day, it

Re: Parsing a string to instantiate classes at runtime

2016-11-27 Thread Marduk via Digitalmars-d-learn
On Sunday, 27 November 2016 at 21:10:30 UTC, ag0aep6g wrote: Can you link that post, please? I can't imagine what "dynamic mixin" could refer to. Sure, it's here: http://forum.dlang.org/post/xmnnsdiuwyjrhkasy...@forum.dlang.org In that thread they also mention Object.factory, but the

Re: Parsing a string to instantiate classes at runtime

2016-11-27 Thread ag0aep6g via Digitalmars-d-learn
On 11/27/2016 10:02 PM, Marduk wrote: I read in an old post in these forums that with a dynamic mixin it is possible to add structures and classes at runtime. I searched "dynamic mixin" but I did not find more information. Can you link that post, please? I can't imagine what "dynamic mixin"

Re: Instantiating a class with different types at runtime

2016-11-27 Thread ag0aep6g via Digitalmars-d-learn
On 11/27/2016 09:52 PM, Marduk wrote: class Example { this(Type_left x, Type_right y) { this.left = x; this.right = y; } Type_left left; Type_right right; } Such that at runtime I can instantiate it with different types: new Example(int a, int b); new

Parsing a string to instantiate classes at runtime

2016-11-27 Thread Marduk via Digitalmars-d-learn
Dear all, I would like to write a program that: 1. Receives a string from the UI 2. Parses the string 3. Instantiates classes, whose names are contained in the string, passing parts of the string as constructor arguments. From my experience with other programming languages, I suppose I need

Re: Instantiating a class with different types at runtime

2016-11-27 Thread Namespace via Digitalmars-d-learn
On Sunday, 27 November 2016 at 20:52:06 UTC, Marduk wrote: Dear all, I would like to have a kind of template class like the following: class Example { this(Type_left x, Type_right y) { this.left = x; this.right = y; } Type_left left; Type_right right; }

Instantiating a class with different types at runtime

2016-11-27 Thread Marduk via Digitalmars-d-learn
Dear all, I would like to have a kind of template class like the following: class Example { this(Type_left x, Type_right y) { this.left = x; this.right = y; } Type_left left; Type_right right; } Such that at runtime I can instantiate it with different types:

Re: Using the result of a comma expression is deprecated

2016-11-27 Thread Adam D. Ruppe via Digitalmars-d-learn
On Sunday, 27 November 2016 at 16:42:17 UTC, Suliman wrote: Am I right understand that `scope(exit)` should be always at top, otherwise it would not work (it's very strange because by the docs it's calling every time when function out of the scopes)? No, scope(exit) queues the thing for

Re: Creating array of structs being used in C interface

2016-11-27 Thread Adam D. Ruppe via Digitalmars-d-learn
On Sunday, 27 November 2016 at 15:56:13 UTC, Stefan Koch wrote: Does your answer also explain why it works when I move the mytypes.d into the source/ folder? dub will link it in when it is in the source folder. exactly.

std.net.curl application throws an exception

2016-11-27 Thread Erdem via Digitalmars-d-learn
try to compile this program from std.net.curl import std.net.curl, std.stdio; void main() { auto range1 = byLineAsync("www.google.com"); auto range2 = byLineAsync("www.wikipedia.org"); foreach (line; byLineAsync("dlang.org")) writeln(line); foreach (line; range1)

Re: Using the result of a comma expression is deprecated

2016-11-27 Thread Suliman via Digitalmars-d-learn
As an aside, for security reasons you should use a prepared statement. Even if it's server-side code and there is no any iteration with user data (they come as JSON) Also, this is a decent usecase for scope(exit) but it should be put earlier in the function. Am I right understand that

Re: Using the result of a comma expression is deprecated

2016-11-27 Thread Suliman via Digitalmars-d-learn
Looks like you forgot a call to format before the opening parenthesis. should be: string sqlinsert = format(`INSERT INTO usersshapes (userlogin, uploading_date, geometry_type, data) VALUES ('%s', '%s', '%s', '%s') `, login, uploading_date, geometry_type, data); because what ends up happening

Re: Creating array of structs being used in C interface

2016-11-27 Thread Stefan Koch via Digitalmars-d-learn
On Sunday, 27 November 2016 at 15:23:33 UTC, Timoses wrote: On Sunday, 27 November 2016 at 14:27:54 UTC, Adam D. Ruppe wrote: That's because int is zero initialized by default and thus doesn't need anything more than a call to zero memory function, and double isn't (it is NaN), so it gets an

Re: Creating array of structs being used in C interface

2016-11-27 Thread Timoses via Digitalmars-d-learn
On Sunday, 27 November 2016 at 14:27:54 UTC, Adam D. Ruppe wrote: That's because int is zero initialized by default and thus doesn't need anything more than a call to zero memory function, and double isn't (it is NaN), so it gets an initializer data blob. If you make it = 0 it might work, but

Re: A simplification of the RvalueRef idiom

2016-11-27 Thread Nick Treleaven via Digitalmars-d-learn
On Friday, 25 November 2016 at 17:21:52 UTC, Nick Treleaven wrote: I've started documenting it now, will post a PR soon. https://github.com/dlang/dlang.org/pull/1519

Re: Creating array of structs being used in C interface

2016-11-27 Thread Adam D. Ruppe via Digitalmars-d-learn
On Sunday, 27 November 2016 at 14:12:31 UTC, Timoses wrote: If I change the union's variable type to "int" (or any other) it compiles just fine. So the problem seems to be the "double" value. That's because int is zero initialized by default and thus doesn't need anything more than a call to

Re: Creating array of structs being used in C interface

2016-11-27 Thread Timoses via Digitalmars-d-learn
On Sunday, 27 November 2016 at 13:22:36 UTC, Nicholas Wilson wrote: The missing symbol is the struct initialiser for neo4j_map_entry_t. Not sure why is not being generated (it should), possibly because of the union. That seems like a bug please report it. http://issues.dlang.org/ Thanks

Re: Creating array of structs being used in C interface

2016-11-27 Thread Adam D. Ruppe via Digitalmars-d-learn
On Sunday, 27 November 2016 at 12:59:32 UTC, Timoses wrote: Why is it a linker problem? I'm not linking to the c interface but merely using D structs... It is a linker problem because you didn't link to it... D structs have an initializer, even if they are used for interfacing with C. This

Re: Creating array of structs being used in C interface

2016-11-27 Thread Nicholas Wilson via Digitalmars-d-learn
On Sunday, 27 November 2016 at 12:59:32 UTC, Timoses wrote: Hi there, I've got a problem interfacing to a C library. The following structs are used by the library's .d file that I've written. struct neo4j_map_entry_t { neo4j_value_t key; neo4j_value_t value; };

Creating array of structs being used in C interface

2016-11-27 Thread Timoses via Digitalmars-d-learn
Hi there, I've got a problem interfacing to a C library. The following structs are used by the library's .d file that I've written. struct neo4j_map_entry_t { neo4j_value_t key; neo4j_value_t value; }; struct neo4j_value_t { uint8_t _vt_off; uint8_t

Re: Using the result of a comma expression is deprecated

2016-11-27 Thread Erik van Velzen via Digitalmars-d-learn
On Sunday, 27 November 2016 at 12:13:03 UTC, Nicholas Wilson wrote: On Sunday, 27 November 2016 at 11:49:25 UTC, Suliman wrote: On Sunday, 27 November 2016 at 11:21:58 UTC, drug007 wrote: void dbInsert(string login, string uploading_date, string geometry_type, string data) {

Re: Using the result of a comma expression is deprecated

2016-11-27 Thread Nicholas Wilson via Digitalmars-d-learn
On Sunday, 27 November 2016 at 11:49:25 UTC, Suliman wrote: On Sunday, 27 November 2016 at 11:21:58 UTC, drug007 wrote: On 27.11.2016 14:07, Suliman wrote: I am getting deprecation message: "Using the result of a comma expression is deprecated" on this code: string sqlinsert = (`INSERT INTO

Re: Using the result of a comma expression is deprecated

2016-11-27 Thread Suliman via Digitalmars-d-learn
On Sunday, 27 November 2016 at 11:21:58 UTC, drug007 wrote: On 27.11.2016 14:07, Suliman wrote: I am getting deprecation message: "Using the result of a comma expression is deprecated" on this code: string sqlinsert = (`INSERT INTO usersshapes (userlogin, uploading_date, geometry_type,

Re: Using the result of a comma expression is deprecated

2016-11-27 Thread drug007 via Digitalmars-d-learn
On 27.11.2016 14:07, Suliman wrote: I am getting deprecation message: "Using the result of a comma expression is deprecated" on this code: string sqlinsert = (`INSERT INTO usersshapes (userlogin, uploading_date, geometry_type, data) VALUES ('%s', '%s', '%s', '%s') `, login, uploading_date,

Using the result of a comma expression is deprecated

2016-11-27 Thread Suliman via Digitalmars-d-learn
I am getting deprecation message: "Using the result of a comma expression is deprecated" on this code: string sqlinsert = (`INSERT INTO usersshapes (userlogin, uploading_date, geometry_type, data) VALUES ('%s', '%s', '%s', '%s') `, login, uploading_date, geometry_type, data); What's wrong

Re: Given two AliasSeq (A and B) and template T, how to make AliasSeq!(T!(A[0], B[0]) ... T!(A[n], B[n])) ?

2016-11-27 Thread Tofu Ninja via Digitalmars-d-learn
On Sunday, 27 November 2016 at 07:38:53 UTC, Nicholas Wilson wrote: Whoops it would help if I read your question. You want to use Iota in conjunction with staticMap. alias pairs(int N, alias a, alias b) = AliasSeq(a[N],b[N]); alias C = staticMap!(T,staticMap(pairs,Iota!N)); That didn't