Re: Getting DUB to work with VS 2017

2017-05-21 Thread Enjoys Math via Digitalmars-d-learn
On Monday, 22 May 2017 at 01:49:48 UTC, Enjoys Math wrote: I did `dub generate visuald project_name`. VS 2017 loads the .sln file except for red 'x's on the dub.json files. My dub.json file looks like (if it matters): { "name": "pegparser", "targetName": "PEGparser",

Getting DUB to work with VS 2017

2017-05-21 Thread Enjoys Math via Digitalmars-d-learn
I did `dub generate visuald project_name`. VS 2017 loads the .sln file except for red 'x's on the dub.json files. My dub.json file looks like (if it matters): { "name": "pegparser", "targetName": "PEGparser", "authors": [ "Fruitful Approach" ],

Re: C++ binding issues with C++ function returning a simple POD struct.

2017-05-21 Thread evilrat via Digitalmars-d-learn
On Monday, 22 May 2017 at 01:27:22 UTC, Nicholas Wilson wrote: On Sunday, 21 May 2017 at 19:33:06 UTC, ParticlePeter wrote: I am statically linking to ImGui [1] on Win 10 x64, quite successfully till this issue came up. The noticed error so far comes when an ImGui function returns an ImVec2, a

Re: C++ binding issues with C++ function returning a simple POD struct.

2017-05-21 Thread Nicholas Wilson via Digitalmars-d-learn
On Sunday, 21 May 2017 at 19:33:06 UTC, ParticlePeter wrote: I am statically linking to ImGui [1] on Win 10 x64, quite successfully till this issue came up. The noticed error so far comes when an ImGui function returns an ImVec2, a simple POD struct of two float members. I can use this struct

Re: Why would an initialised struct pointer field be null in the struct's destructor?

2017-05-21 Thread Stanislav Blinov via Digitalmars-d-learn
On Monday, 22 May 2017 at 00:45:27 UTC, Adam D. Ruppe wrote: On Monday, 22 May 2017 at 00:36:24 UTC, Stanislav Blinov wrote: I can't think of any case where you'd want preconditions on destructor when the object is in .init state. I think we're actually saying the same thing: I mean the

Re: Why would an initialised struct pointer field be null in the struct's destructor?

2017-05-21 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 22 May 2017 at 00:36:24 UTC, Stanislav Blinov wrote: I can't think of any case where you'd want preconditions on destructor when the object is in .init state. I think we're actually saying the same thing: I mean the destructor must be callable on .init so you might do like struct

Re: Why would an initialised struct pointer field be null in the struct's destructor?

2017-05-21 Thread Stanislav Blinov via Digitalmars-d-learn
On Monday, 22 May 2017 at 00:23:26 UTC, Adam D. Ruppe wrote: On Sunday, 21 May 2017 at 14:13:20 UTC, Stanislav Blinov wrote: Not if you either emplace() or blit Foo.init into all of the array elements. You especially need to be safe calling ~this on Foo.init. How so? .init is supposed to be

Re: Why would an initialised struct pointer field be null in the struct's destructor?

2017-05-21 Thread Adam D. Ruppe via Digitalmars-d-learn
On Sunday, 21 May 2017 at 14:13:20 UTC, Stanislav Blinov wrote: Not if you either emplace() or blit Foo.init into all of the array elements. You especially need to be safe calling ~this on Foo.init.

Re: Why would an initialised struct pointer field be null in the struct's destructor?

2017-05-21 Thread Stanislav Blinov via Digitalmars-d-learn
On Sunday, 21 May 2017 at 23:59:08 UTC, Guillaume Piolat wrote: On Sunday, 21 May 2017 at 12:48:10 UTC, Adam D. Ruppe wrote: Any struct should be able to have its destructor called Does this rule also applies to class objects? Yes. If your destructor does modify the state, you should expect

Re: Why would an initialised struct pointer field be null in the struct's destructor?

2017-05-21 Thread Guillaume Piolat via Digitalmars-d-learn
On Sunday, 21 May 2017 at 12:48:10 UTC, Adam D. Ruppe wrote: Any struct should be able to have its destructor called Does this rule also applies to class objects?

Re: C++ binding issues with C++ function returning a simple POD struct.

2017-05-21 Thread ParticlePeter via Digitalmars-d-learn
On Sunday, 21 May 2017 at 19:58:32 UTC, Stefan Koch wrote: On Sunday, 21 May 2017 at 19:33:06 UTC, ParticlePeter wrote: I am statically linking to ImGui [1] on Win 10 x64, quite successfully till this issue came up. The noticed error so far comes when an ImGui function returns an ImVec2, a

Re: C++ binding issues with C++ function returning a simple POD struct.

2017-05-21 Thread Stefan Koch via Digitalmars-d-learn
On Sunday, 21 May 2017 at 19:33:06 UTC, ParticlePeter wrote: I am statically linking to ImGui [1] on Win 10 x64, quite successfully till this issue came up. The noticed error so far comes when an ImGui function returns an ImVec2, a simple POD struct of two float members. I can use this struct

C++ binding issues with C++ function returning a simple POD struct.

2017-05-21 Thread ParticlePeter via Digitalmars-d-learn
I am statically linking to ImGui [1] on Win 10 x64, quite successfully till this issue came up. The noticed error so far comes when an ImGui function returns an ImVec2, a simple POD struct of two float members. I can use this struct as argument to functions but when it is returned from a

Re: Is there websocket client implementation for D

2017-05-21 Thread aberba via Digitalmars-d-learn
On Wednesday, 25 March 2015 at 15:46:31 UTC, Adam D. Ruppe wrote: On Wednesday, 25 March 2015 at 07:12:56 UTC, thedeemon wrote: It's for server side, but probably contains stuff you need for client too. Yeah, I've been meaning to write a client for a while but haven't gotten around to it

WebSocket lib

2017-05-21 Thread aberba via Digitalmars-d-learn
Which one would you recommended for working with browser socket client and D-based client (abstracted aoi)?

Re: Multiple template variadic list not working

2017-05-21 Thread bastien penavayre via Digitalmars-d-learn
On Sunday, 21 May 2017 at 15:30:38 UTC, Stanislav Blinov wrote: In this case, eponymous template should do the trick: template func(UserArgs...) { void func(Arguments...)(Arguments args) {} } Ah I see, I didn't know of this technique. Thanks.

Re: Multiple template variadic list not working

2017-05-21 Thread Stanislav Blinov via Digitalmars-d-learn
On Sunday, 21 May 2017 at 15:13:55 UTC, bastien penavayre wrote: I've been trying to translate the following idea expressed here in c++: template void func(Arguments... args) {} so I tried void func(UserArgs..., Arguments...)(Arguments args) {} and then void func(Args...)(Filter!(isType,

Re: Multiple template variadic list not working

2017-05-21 Thread bastien penavayre via Digitalmars-d-learn
On Sunday, 21 May 2017 at 15:16:55 UTC, Stefan Koch wrote: How would that work ? How would I know where UserArgs end, and Arguments begin ? func!(UserArgs here)(Arguments values here); C++ does it without any problem. I don't see what prevent D from doing it.

Re: Multiple template variadic list not working

2017-05-21 Thread Stefan Koch via Digitalmars-d-learn
On Sunday, 21 May 2017 at 15:13:55 UTC, bastien penavayre wrote: I've been trying to translate the following idea expressed here in c++: template void func(Arguments... args) {} so I tried void func(UserArgs..., Arguments...)(Arguments args) {} and then void func(Args...)(Filter!(isType,

Multiple template variadic list not working

2017-05-21 Thread bastien penavayre via Digitalmars-d-learn
I've been trying to translate the following idea expressed here in c++: template void func(Arguments... args) {} so I tried void func(UserArgs..., Arguments...)(Arguments args) {} and then void func(Args...)(Filter!(isType, Args) args) {} but nothing works. This seems like something

Re: Why would an initialised struct pointer field be null in the struct's destructor?

2017-05-21 Thread Stanislav Blinov via Digitalmars-d-learn
On Sunday, 21 May 2017 at 12:48:10 UTC, Adam D. Ruppe wrote: On Saturday, 20 May 2017 at 10:48:54 UTC, Gary Willoughby wrote: // Why is this._foo null here??? The others have answered why and what to do, but note that according to the spec, that any struct should be able to

Re: Why would an initialised struct pointer field be null in the struct's destructor?

2017-05-21 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 20 May 2017 at 10:48:54 UTC, Gary Willoughby wrote: // Why is this._foo null here??? The others have answered why and what to do, but note that according to the spec, that any struct should be able to have its destructor called, so you should do a null check in

Re: Why is DUB not passing dll.def file to linker

2017-05-21 Thread Igor via Digitalmars-d-learn
On Sunday, 21 May 2017 at 11:47:15 UTC, Mike Parker wrote: So what I would try in your situation is to add three new configurations to the exeProject's dub.json. Use the "platforms" directive to limit one to "windows-x86", another to "windows-x86_64", and leave the other one empty. List the

Re: Why would an initialised struct pointer field be null in the struct's destructor?

2017-05-21 Thread Eduard Staniloiu via Digitalmars-d-learn
On Saturday, 20 May 2017 at 10:48:54 UTC, Gary Willoughby wrote: Looks like you would want to use emplace [0] here. public this(int n) { this._data = (cast(Foo*) calloc(n, Foo.sizeof))[0 .. n]; foreach(ref element; this._data) {

Re: Why is DUB not passing dll.def file to linker

2017-05-21 Thread Mike Parker via Digitalmars-d-learn
On Sunday, 21 May 2017 at 11:42:02 UTC, Mike Parker wrote: On Sunday, 21 May 2017 at 10:53:42 UTC, Igor wrote: Dynamic libraries are not yet supported as dependencies - building as static library. I see. And I'm not surprised. DLL support on Windows (at least in DMD, not sure about LDC)

Re: Why is DUB not passing dll.def file to linker

2017-05-21 Thread Mike Parker via Digitalmars-d-learn
On Sunday, 21 May 2017 at 10:53:42 UTC, Igor wrote: Dynamic libraries are not yet supported as dependencies - building as static library. I see. And I'm not surprised. DLL support on Windows (at least in DMD, not sure about LDC) is still not where it needs to be. I don't know how much has

Re: Why is DUB not passing dll.def file to linker

2017-05-21 Thread Igor via Digitalmars-d-learn
On Sunday, 21 May 2017 at 10:15:40 UTC, Mike Parker wrote: Then you can add the following to exeProject/dub.json: "dependencies": { "dllProjectName": {"path" : "../dllProject" } } I would expect the import lib to be linked automatically. This should ensure the dll is compiled with the

Re: Why is DUB not passing dll.def file to linker

2017-05-21 Thread Mike Parker via Digitalmars-d-learn
On Sunday, 21 May 2017 at 09:37:56 UTC, Igor wrote: If I now run dub build in main project both projects compile and work together, but if I run dub build -ax86_64 only main project is built as 64bit while dll project is still being built as 32bit. Does anyone have a suggestion how can I make

Re: Implicit conversion from 'Ok' to 'Result' type when returning functions

2017-05-21 Thread Nicholas Wilson via Digitalmars-d-learn
On Sunday, 21 May 2017 at 09:55:41 UTC, David Zhang wrote: On Sunday, 21 May 2017 at 09:37:46 UTC, Nicholas Wilson wrote: On Sunday, 21 May 2017 at 09:29:40 UTC, David Zhang wrote: Well then it becomes Result!(T, E) ok(T,E) (T t) { return Result(t); } Result!(T, E) error(T,E)(E e) {

Re: Implicit conversion from 'Ok' to 'Result' type when returning functions

2017-05-21 Thread David Zhang via Digitalmars-d-learn
On Sunday, 21 May 2017 at 09:37:46 UTC, Nicholas Wilson wrote: On Sunday, 21 May 2017 at 09:29:40 UTC, David Zhang wrote: Well then it becomes Result!(T, E) ok(T,E) (T t) { return Result(t); } Result!(T, E) error(T,E)(E e) { return Result(e); } and then provided it can be inferred (e.g.

Re: Why is DUB not passing dll.def file to linker

2017-05-21 Thread Igor via Digitalmars-d-learn
On Saturday, 20 May 2017 at 21:36:42 UTC, Mike Parker wrote: On Saturday, 20 May 2017 at 20:26:29 UTC, Igor wrote: So my question is if the fix is so simple what are the reasons it isn't implemented? Am I missing something? I don't know, but you could always submit a PR or an enhancement

Re: Implicit conversion from 'Ok' to 'Result' type when returning functions

2017-05-21 Thread Nicholas Wilson via Digitalmars-d-learn
On Sunday, 21 May 2017 at 09:29:40 UTC, David Zhang wrote: On Sunday, 21 May 2017 at 09:15:56 UTC, Nicholas Wilson wrote: have free functions Result!(T, ErrorEnum) ok(T)(T t) { return Result(t); } Result!(T, ErrorEnum) error(T)(ErrorEnum e) { return Result(e); } then go if (!foo)

Re: Implicit conversion from 'Ok' to 'Result' type when returning functions

2017-05-21 Thread David Zhang via Digitalmars-d-learn
On Sunday, 21 May 2017 at 09:15:56 UTC, Nicholas Wilson wrote: have free functions Result!(T, ErrorEnum) ok(T)(T t) { return Result(t); } Result!(T, ErrorEnum) error(T)(ErrorEnum e) { return Result(e); } then go if (!foo) return ok(42); else return error(Error.fooHappened); Ah,

Re: Implicit conversion from 'Ok' to 'Result' type when returning functions

2017-05-21 Thread Nicholas Wilson via Digitalmars-d-learn
On Sunday, 21 May 2017 at 08:44:31 UTC, David Zhang wrote: Hi, I was reading a bit about this in Rust, and their enum type. I was wondering if this is replicate-able in D. What I've got right now is rather clunky, and involves using `typeof(return).ok` and `typeof(return).error)`.

Implicit conversion from 'Ok' to 'Result' type when returning functions

2017-05-21 Thread David Zhang via Digitalmars-d-learn
Hi, I was reading a bit about this in Rust, and their enum type. I was wondering if this is replicate-able in D. What I've got right now is rather clunky, and involves using `typeof(return).ok` and `typeof(return).error)`. While that's not too bad, it does involve a lot more typing,

Re: Fluent APIs

2017-05-21 Thread Nicholas Wilson via Digitalmars-d-learn
On Sunday, 21 May 2017 at 05:18:33 UTC, Russel Winder wrote: I am having a crisis of confidence. In two places I have structurally: datum.action() .map!(…) and then the fun starts as I need to actually do a flatMap. In one of the two places I have to: .array .joiner; but