How to call a method of class D from function of C++ in DLL?

2016-08-26 Thread MGW via Digitalmars-d-learn
Method which I use now: source D: - extern (C) { int on_metFromD(CEditWin* uk, int aa, int bb) { return (*uk).metFromD(int aa, int bb); } } class CEditWin { . . . // Method for to call int metFromD(int a, int b) { return a + b; } } main() {

Re: Judy Arrays

2016-08-26 Thread Alex via Digitalmars-d-learn
On Thursday, 25 August 2016 at 20:43:19 UTC, Illuminati wrote: On Thursday, 25 August 2016 at 20:42:42 UTC, Illuminati wrote: http://judy.sourceforge.net/downloads/10minutes.htm Would be nice to have such an implementation. Supposedly one of the best all around data structures in existence?

Re: Does D have any construct like Python's with keyword?

2016-08-26 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 27 August 2016 at 00:04:47 UTC, pineapple wrote: context(auto file = File("some_file.txt")){ file.write(); } You don't need to do anything special for that in D, structs are destructed automatically. Plain auto file = File("some_file.txt"); file.write(); will

Re: Proper concurrent nearly lock free efficient nogc storage structures?

2016-08-26 Thread Illuminati via Digitalmars-d-learn
On Friday, 26 August 2016 at 23:44:53 UTC, Cauterite wrote: On Friday, 26 August 2016 at 23:38:02 UTC, Illuminati wrote: Does D have any such thing? I'm having to recreate the wheel here and it isn't fun ;/ Getting in the way of real work ;/ @nogc is such a new language feature that you

Re: Does D have any construct like Python's with keyword?

2016-08-26 Thread pineapple via Digitalmars-d-learn
I would just love if I could express this as something more like context(auto file = File("some_file.txt")){ file.write(); }

Re: Does D have any construct like Python's with keyword?

2016-08-26 Thread pineapple via Digitalmars-d-learn
On Friday, 26 August 2016 at 23:30:15 UTC, Cauterite wrote: On Friday, 26 August 2016 at 23:28:27 UTC, pineapple wrote: I've grown to very much appreciate how context initialization and teardown can be very conveniently handled using `with` in Python. Is there any clean way to imitate this

Re: Proper concurrent nearly lock free efficient nogc storage structures?

2016-08-26 Thread Cauterite via Digitalmars-d-learn
On Friday, 26 August 2016 at 23:38:02 UTC, Illuminati wrote: Does D have any such thing? I'm having to recreate the wheel here and it isn't fun ;/ Getting in the way of real work ;/ @nogc is such a new language feature that you can't expect a lot of support yet from e.g. the standard

Proper concurrent nearly lock free efficient nogc storage structures?

2016-08-26 Thread Illuminati via Digitalmars-d-learn
Does D have any such thing? I'm having to recreate the wheel here and it isn't fun ;/ Getting in the way of real work ;/ Surely you would think that with the power D has such things would exist by now?

Re: Does D have any construct like Python's with keyword?

2016-08-26 Thread Cauterite via Digitalmars-d-learn
On Friday, 26 August 2016 at 23:28:27 UTC, pineapple wrote: I've grown to very much appreciate how context initialization and teardown can be very conveniently handled using `with` in Python. Is there any clean way to imitate this syntax in D? Yep, scope guards. auto p = OpenProcess(...);

Does D have any construct like Python's with keyword?

2016-08-26 Thread pineapple via Digitalmars-d-learn
I've grown to very much appreciate how context initialization and teardown can be very conveniently handled using `with` in Python. Is there any clean way to imitate this syntax in D?

Re: using .init reliably

2016-08-26 Thread Cauterite via Digitalmars-d-learn
On Friday, 26 August 2016 at 15:14:42 UTC, Steven Schveighoffer wrote: FYI, you cannot make this patch until we fully deprecate the use of TypeInfo.init: https://github.com/dlang/druntime/blob/master/src/object.d#L294 So at least until 2.075. -Steve Ah yes, good thinking. I'll keep that in

Re: using .init reliably

2016-08-26 Thread Steven Schveighoffer via Digitalmars-d-learn
On 8/26/16 6:52 AM, Cauterite wrote: On Friday, 26 August 2016 at 09:48:00 UTC, Jonathan M Davis wrote: And I expect that it will become an error at some point in the future to define an init member for a user-defined type, at which point, there won't be any choice about fixing it. I might

Re: using .init reliably

2016-08-26 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, August 26, 2016 10:52:47 Cauterite via Digitalmars-d-learn wrote: > On Friday, 26 August 2016 at 09:48:00 UTC, Jonathan M Davis wrote: > > And I expect that it will become an error at some point in the > > future to define an init member for a user-defined type, at > > which point,

Re: using .init reliably

2016-08-26 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, August 26, 2016 11:20:56 Johan Engelen via Digitalmars-d-learn wrote: > On Friday, 26 August 2016 at 09:48:00 UTC, Jonathan M Davis wrote: > > You're supposed to be able to depend on .init existing. Default > > initialization for structs can be disabled via > > > > @disable this(); > >

Re: using .init reliably

2016-08-26 Thread Johan Engelen via Digitalmars-d-learn
On Friday, 26 August 2016 at 09:48:00 UTC, Jonathan M Davis wrote: You're supposed to be able to depend on .init existing. Default initialization for structs can be disabled via @disable this(); but even then, the init member still exists (it just isn't used for default initialization).

Re: using .init reliably

2016-08-26 Thread Cauterite via Digitalmars-d-learn
On Friday, 26 August 2016 at 09:48:00 UTC, Jonathan M Davis wrote: And I expect that it will become an error at some point in the future to define an init member for a user-defined type, at which point, there won't be any choice about fixing it. I might take a crack at this patch. Sounds

Re: copy a JSONValue

2016-08-26 Thread Alex via Digitalmars-d-learn
On Friday, 26 August 2016 at 08:21:14 UTC, Alex wrote: On Friday, 26 August 2016 at 07:20:00 UTC, Daniel Kozak wrote: auto j2 = j.toString.parseJSON; ha! cool! thanks! :) found a bug... https://issues.dlang.org/show_bug.cgi?id=16432 not very serious... but not found yet? ;)

Re: using .init reliably

2016-08-26 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, August 26, 2016 08:59:55 Cauterite via Digitalmars-d-learn wrote: > How can I get the initial value of an arbitrary type? Since any > struct can override it, .init is not reliable: > > struct Z { > enum init = 6; > string val = `asdf`; > }; > assert(Z.init == 6); >

using .init reliably

2016-08-26 Thread Cauterite via Digitalmars-d-learn
How can I get the initial value of an arbitrary type? Since any struct can override it, .init is not reliable: struct Z { enum init = 6; string val = `asdf`; }; assert(Z.init == 6); assert(typeof(Z()).init == 6); I know I could use *(cast(Z*) typeid(Z).initializer.ptr) but that

Re: copy a JSONValue

2016-08-26 Thread Alex via Digitalmars-d-learn
On Friday, 26 August 2016 at 07:46:13 UTC, Daniel Kozak wrote: Another way is to implement deepCopy by yourself (something like below) import std.json; import std.stdio; JSONValue deepCopy(ref JSONValue val) { JSONValue newVal; switch(val.type) { case JSON_TYPE.STRING:

Re: copy a JSONValue

2016-08-26 Thread Alex via Digitalmars-d-learn
On Friday, 26 August 2016 at 07:20:00 UTC, Daniel Kozak wrote: auto j2 = j.toString.parseJSON; ha! cool! thanks! :)

Re: copy a JSONValue

2016-08-26 Thread Daniel Kozak via Digitalmars-d-learn
On Friday, 26 August 2016 at 06:56:06 UTC, Alex wrote: Hi everybody, I'm little at loss: as documented, a JSONValue is only shallow copied: ... So the effect that the code of "j" is altered was expected. The question is: how to make a deep copy of a JSONValue? Is there a simple way without

Re: build dll project use VisualD with the "Use MS-COFF object file..." setting selected failed

2016-08-26 Thread magicdmer via Digitalmars-d-learn
On Friday, 26 August 2016 at 07:21:55 UTC, Daniel Kozak wrote: Dne 26.8.2016 v 09:12 magicdmer via Digitalmars-d-learn can you try it from console? something like dmd.exe -m32mscoff your_d_file.d same error , it's only dll project like this. console project can build successfully with the

Re: build dll project use VisualD with the "Use MS-COFF object file..." setting selected failed

2016-08-26 Thread Daniel Kozak via Digitalmars-d-learn
Dne 26.8.2016 v 09:12 magicdmer via Digitalmars-d-learn napsal(a): On Friday, 26 August 2016 at 07:00:37 UTC, rikki cattermole wrote: Okay so your Windows language is non-english, that'll be it. You need to be looking into the encoding that Visual Studio is using for you files. Something to

Re: copy a JSONValue

2016-08-26 Thread Daniel Kozak via Digitalmars-d-learn
Dne 26.8.2016 v 08:56 Alex via Digitalmars-d-learn napsal(a): void main() { import std.json; import std.stdio; string s = "{ \"language\": \"D\", \"rating\": 3.14, \"code\": 42 }"; JSONValue j = parseJSON(s); writeln("code: ", j["code"].integer); auto j2 = j;

Re: build dll project use VisualD with the "Use MS-COFF object file..." setting selected failed

2016-08-26 Thread magicdmer via Digitalmars-d-learn
On Friday, 26 August 2016 at 07:00:37 UTC, rikki cattermole wrote: Okay so your Windows language is non-english, that'll be it. You need to be looking into the encoding that Visual Studio is using for you files. Something to do with the BOM or hasn't even been set to utf-8 isn't quite right.

Re: build dll project use VisualD with the "Use MS-COFF object file..." setting selected failed

2016-08-26 Thread Daniel Kozak via Digitalmars-d-learn
Dne 26.8.2016 v 08:52 magicdmer via Digitalmars-d-learn napsal(a): On Friday, 26 August 2016 at 06:38:01 UTC, Daniel Kozak wrote: That image is too small, so I can't see it :) Dne 26.8.2016 v 08:26 magicdmer via Digitalmars-d-learn napsal(a): I use VisualD create a windows dll project , and

Re: build dll project use VisualD with the "Use MS-COFF object file..." setting selected failed

2016-08-26 Thread rikki cattermole via Digitalmars-d-learn
On 26/08/2016 6:52 PM, magicdmer wrote: On Friday, 26 August 2016 at 06:38:01 UTC, Daniel Kozak wrote: That image is too small, so I can't see it :) Dne 26.8.2016 v 08:26 magicdmer via Digitalmars-d-learn napsal(a): I use VisualD create a windows dll project , and select the "Use MS-COFF

copy a JSONValue

2016-08-26 Thread Alex via Digitalmars-d-learn
Hi everybody, I'm little at loss: as documented, a JSONValue is only shallow copied: void main() { import std.json; import std.stdio; string s = "{ \"language\": \"D\", \"rating\": 3.14, \"code\": 42 }"; JSONValue j = parseJSON(s); writeln("code: ", j["code"].integer);

Re: build dll project use VisualD with the "Use MS-COFF object file..." setting selected failed

2016-08-26 Thread magicdmer via Digitalmars-d-learn
On Friday, 26 August 2016 at 06:38:01 UTC, Daniel Kozak wrote: That image is too small, so I can't see it :) Dne 26.8.2016 v 08:26 magicdmer via Digitalmars-d-learn napsal(a): I use VisualD create a windows dll project , and select the "Use MS-COFF object file fromat for win32" . when i build

Re: build dll project use VisualD with the "Use MS-COFF object file..." setting selected failed

2016-08-26 Thread Daniel Kozak via Digitalmars-d-learn
That image is too small, so I can't see it :) Dne 26.8.2016 v 08:26 magicdmer via Digitalmars-d-learn napsal(a): I use VisualD create a windows dll project , and select the "Use MS-COFF object file fromat for win32" . when i build it ,it display the error follow ,look at the picture I use

build dll project use VisualD with the "Use MS-COFF object file..." setting selected failed

2016-08-26 Thread magicdmer via Digitalmars-d-learn
I use VisualD create a windows dll project , and select the "Use MS-COFF object file fromat for win32" . when i build it ,it display the error follow ,look at the picture I use dmd 2.071.1 https://s14.postimg.org/a4wcv74ct/image.png