Re: using new in shared library causes access violation

2015-06-26 Thread Adam D. Ruppe via Digitalmars-d-learn
Did you call Runtime.initialized in the D side of that initialization fucntion?

Re: Abstract sockets (linux)

2015-06-26 Thread Kagamin via Digitalmars-d-learn
On Friday, 26 June 2015 at 13:36:49 UTC, freeman wrote: This works (socat): connect(3, {sa_family=AF_FILE, path=@/var/run/ptmd.socket}, 23) = 0 This does not (from deneme, modified): connect(3, {sa_family=AF_FILE, path=@/var/run/ptmd.socket}, 24) = -1 ECONNREFUSED (Connection

Re: using new in shared library causes access violation

2015-06-26 Thread dd0s via Digitalmars-d-learn
On Friday, 26 June 2015 at 16:32:44 UTC, Adam D. Ruppe wrote: Did you call Runtime.initialized in the D side of that initialization fucntion? No i wasn't aware of that. Thank you so much Adam. I still don't know what it does exactly but i just call it when OnPluginInit() is called. Are you

Re: Help the old man learn D

2015-06-26 Thread Charles Hawkins via Digitalmars-d-learn
On Friday, 26 June 2015 at 15:33:25 UTC, Charles Hawkins wrote: On Friday, 26 June 2015 at 14:52:51 UTC, Marc Schütz wrote: On Friday, 26 June 2015 at 14:39:05 UTC, Charles Hawkins wrote: [...] I think I've answered my own question regarding the callbacks as well. I realized that the only

using new in shared library causes access violation

2015-06-26 Thread dd0s via Digitalmars-d-learn
hi, I have a c++ program with a plugin system and i try to write a plugin for it. when the plugin is loaded by the program the extern (C) int OnInit() method is called. so far everything works fine. But as soon as i try to create a new class instance a segmentation fault occurs ( the

Re: Help the old man learn D

2015-06-26 Thread via Digitalmars-d-learn
On Friday, 26 June 2015 at 14:39:05 UTC, Charles Hawkins wrote: Thanks. I've changed to thread topic to Help the old man learn D. :) logger package allows those statements to compile with gdc although I'm now getting lots of errors saying undefined identifier format even though I'm importing

Re: Abstract sockets (linux)

2015-06-26 Thread freeman via Digitalmars-d-learn
On Thursday, 25 June 2015 at 15:56:06 UTC, freeman wrote: I am having trouble using abstract sockets on Linux. Here is sample python code that works, which works: ptm_sockname = \0/var/run/ptmd.socket sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)

Help the old man learn D

2015-06-26 Thread Charles Hawkins via Digitalmars-d-learn
On Wednesday, 24 June 2015 at 16:21:47 UTC, weaselcat wrote: On Wednesday, 24 June 2015 at 07:52:10 UTC, Charles Hawkins wrote: On Wednesday, 24 June 2015 at 06:54:57 UTC, weaselcat wrote: On Tuesday, 23 June 2015 at 06:50:28 UTC, Charles Hawkins wrote: [...] you can instruct dub to use

Re: Help the old man learn D

2015-06-26 Thread Charles Hawkins via Digitalmars-d-learn
On Friday, 26 June 2015 at 14:52:51 UTC, Marc Schütz wrote: On Friday, 26 June 2015 at 14:39:05 UTC, Charles Hawkins wrote: Thanks. I've changed to thread topic to Help the old man learn D. :) logger package allows those statements to compile with gdc although I'm now getting lots of errors

Re: Help the old man learn D

2015-06-26 Thread via Digitalmars-d-learn
On Friday, 26 June 2015 at 16:57:14 UTC, Charles Hawkins wrote: Sorry for talking to myself, but I'm hoping someone will help me out. The above idea doesn't work. It appears that only the main program file is going to have function pointers while modules and classes will have delegates. So,

Re: Abstract sockets (linux)

2015-06-26 Thread Ali Çehreli via Digitalmars-d-learn
On 06/26/2015 07:39 AM, freeman wrote: Is this worthy of a bug report? If it's a bug, yes. :) Ali

Why aren't Ranges Interfaces?

2015-06-26 Thread Jack Stouffer via Digitalmars-d-learn
I have been learning D over the past three weeks and I came to the chapter in Programming in D on Ranges. And I am a little confused on the choice to make Ranges based on the methods you have in the struct, but not use a interface. With all of the isInputRange!R you have to write everywhere,

Re: Why aren't Ranges Interfaces?

2015-06-26 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 26 June 2015 at 18:37:51 UTC, Jack Stouffer wrote: The only reason I can think of to not do it this way is the weird distinction between structs and classes in D. If anything, C++ is the weird one in having two keywords that mean the same thing... But the reason comes down to

Re: Why aren't Ranges Interfaces?

2015-06-26 Thread Jack Stouffer via Digitalmars-d-learn
Thanks for the reply! I understand the reasoning now. On Friday, 26 June 2015 at 18:46:03 UTC, Adam D. Ruppe wrote: 2) interfaces have an associated runtime cost, which ranges wanted to avoid. They come with hidden function pointers and if you actually use it through them, you can get a

Re: Why aren't Ranges Interfaces?

2015-06-26 Thread Jack Stouffer via Digitalmars-d-learn
On Friday, 26 June 2015 at 19:40:41 UTC, rsw0x wrote: On Friday, 26 June 2015 at 19:26:57 UTC, Jack Stouffer wrote: Thanks for the reply! I understand the reasoning now. On Friday, 26 June 2015 at 18:46:03 UTC, Adam D. Ruppe wrote: 2) interfaces have an associated runtime cost, which ranges

Re: Why aren't Ranges Interfaces?

2015-06-26 Thread Ali Çehreli via Digitalmars-d-learn
On 06/26/2015 11:37 AM, Jack Stouffer wrote: easier if the different types of Ranges where just interfaces that you could inherit from. If you think you need polymorphic interfaces, the next chapter talks about inputRangeObject():

Re: Why aren't Ranges Interfaces?

2015-06-26 Thread rsw0x via Digitalmars-d-learn
On Friday, 26 June 2015 at 19:26:57 UTC, Jack Stouffer wrote: Thanks for the reply! I understand the reasoning now. On Friday, 26 June 2015 at 18:46:03 UTC, Adam D. Ruppe wrote: 2) interfaces have an associated runtime cost, which ranges wanted to avoid. They come with hidden function pointers

Re: Why aren't Ranges Interfaces?

2015-06-26 Thread Dicebot via Digitalmars-d-learn
On Friday, 26 June 2015 at 19:26:57 UTC, Jack Stouffer wrote: How much of a performance hit are we talking about? Is the difference between using an interface and not using one noticeable? It can be huge difference if you take inlning in mind. LDC is capable of flattening most simple

Re: Typed Message Passing between D Processes

2015-06-26 Thread Laeeth Isharc via Digitalmars-d-learn
On Friday, 26 June 2015 at 11:13:11 UTC, Per Nordlöw wrote: On Friday, 26 June 2015 at 10:23:26 UTC, Laeeth Isharc wrote: On Friday, 26 June 2015 at 09:06:18 UTC, Per Nordlöw wrote: On Thursday, 25 June 2015 at 23:23:01 UTC, Laeeth Isharc wrote: not sure if this is quite what you are looking

Re: Why aren't Ranges Interfaces?

2015-06-26 Thread rsw0x via Digitalmars-d-learn
On Friday, 26 June 2015 at 18:37:51 UTC, Jack Stouffer wrote: I have been learning D over the past three weeks and I came to the chapter in Programming in D on Ranges. And I am a little confused on the choice to make Ranges based on the methods you have in the struct, but not use a interface.

Re: Why aren't Ranges Interfaces?

2015-06-26 Thread Justin Whear via Digitalmars-d-learn
On Fri, 26 Jun 2015 19:26:56 +, Jack Stouffer wrote: Thanks for the reply! I understand the reasoning now. On Friday, 26 June 2015 at 18:46:03 UTC, Adam D. Ruppe wrote: 2) interfaces have an associated runtime cost, which ranges wanted to avoid. They come with hidden function pointers

Re: function default parameters lost

2015-06-26 Thread Paul D Anderson via Digitalmars-d-learn
On Thursday, 25 June 2015 at 14:17:13 UTC, Paul D Anderson wrote: On Thursday, 25 June 2015 at 07:10:57 UTC, tcak wrote: On Thursday, 25 June 2015 at 04:43:51 UTC, Paul D Anderson wrote: I'm trying to pass a function pointer while keeping the default parameter values intact. Given the

Re: how do I create an array of objects as member of class?

2015-06-26 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 26 June 2015 at 21:50:30 UTC, Assembly wrote: class Baa { Foo a = new Foo(); Foo b = new Foo(); Foo[] l = [a,b]; Keep in mind that those instances are *static* and probably not what you expect; modifying a will be seen across all instances of Baa unless you actually assign

Re: Typed Message Passing between D Processes

2015-06-26 Thread Atila Neves via Digitalmars-d-learn
On Friday, 26 June 2015 at 12:31:04 UTC, Dicebot wrote: std.concurrency was supposed to be able to handle that by design but it is impossible to do without any sort of standard serialization utility in Phobos (and, ideally, very fast binary serialization utility) I'd have to benchmark it

Static constructors guaranteed to run?

2015-06-26 Thread Tofu Ninja via Digitalmars-d-learn
Are static constructors guaranteed to run if the module is imported? Also are static constructors in templated types guaranteed to run for every instantiation? Even if the instantiation is never actually used outside of compile time code, like in an alias or in a UDA?

how do I create an array of objects as member of class?

2015-06-26 Thread Assembly via Digitalmars-d-learn
Imaginary code: class Foo { } class Baa { Foo a = new Foo(); Foo b = new Foo(); Foo[] l = [a,b]; } What should I use instead of to it work? Array!Foo(a,b) didn't worked either. I know this works: class Baa { Foo a = new Foo(); Foo b = new Foo(); Foo[] l; this() { l = [a,b]; }

Re: Typed Message Passing between D Processes

2015-06-26 Thread via Digitalmars-d-learn
On Thursday, 25 June 2015 at 23:23:01 UTC, Laeeth Isharc wrote: not sure if this is quite what you are looking for, or if the performance overhead is acceptable but have you looked at msgpack to go on top of a lower level pipe ? Why is a lower-level pipe needed, when we have pipe in

string to time conversion (when string contains time but no date)

2015-06-26 Thread Timothee Cour via Digitalmars-d-learn
is there a way to convert a string representing a time (without date) to a time, eg: auto t = 19:03:40.143656; auto a=SysTime.fromTimeString(t); // doesn't exist My current workaround is to append a dummy date before and then calling SysTime.fromSimpleString. Is there a better way? seems

Re: Typed Message Passing between D Processes

2015-06-26 Thread Laeeth Isharc via Digitalmars-d-learn
On Friday, 26 June 2015 at 09:06:18 UTC, Per Nordlöw wrote: On Thursday, 25 June 2015 at 23:23:01 UTC, Laeeth Isharc wrote: not sure if this is quite what you are looking for, or if the performance overhead is acceptable but have you looked at msgpack to go on top of a lower level pipe ? Why

Re: Struct vs. Class

2015-06-26 Thread Daniel Kozák via Digitalmars-d-learn
On Fri, 26 Jun 2015 11:11:15 + Chris via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: I have still some classes lying around in my code. As threading is becoming more and more of an issue, classes and OOP in general turn out to be a nuisance. It's not so hard to turn the

Re: Abstract sockets (linux)

2015-06-26 Thread freeman via Digitalmars-d-learn
On Thursday, 25 June 2015 at 19:47:37 UTC, Ali Çehreli wrote: I've found an old example of mine, which uses abstract sockets. Apparently, it was a concurrency experiment as well. Just translated from Turkish to English: http://ddili.org/ornek_kod/client_server.d One difference I see is

Re: Struct vs. Class

2015-06-26 Thread Daniel Kozák via Digitalmars-d-learn
On Fri, 26 Jun 2015 11:11:15 + Chris via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: I have still some classes lying around in my code. As threading is becoming more and more of an issue, classes and OOP in general turn out to be a nuisance. It's not so hard to turn the

Re: Typed Message Passing between D Processes

2015-06-26 Thread Dicebot via Digitalmars-d-learn
std.concurrency was supposed to be able to handle that by design but it is impossible to do without any sort of standard serialization utility in Phobos (and, ideally, very fast binary serialization utility)

Re: Typed Message Passing between D Processes

2015-06-26 Thread via Digitalmars-d-learn
On Friday, 26 June 2015 at 10:23:26 UTC, Laeeth Isharc wrote: On Friday, 26 June 2015 at 09:06:18 UTC, Per Nordlöw wrote: On Thursday, 25 June 2015 at 23:23:01 UTC, Laeeth Isharc wrote: not sure if this is quite what you are looking for, or if the performance overhead is acceptable but have

Struct vs. Class

2015-06-26 Thread Chris via Digitalmars-d-learn
I have still some classes lying around in my code. As threading is becoming more and more of an issue, classes and OOP in general turn out to be a nuisance. It's not so hard to turn the classes into structs, a lot of classes are in fact singletons (yes, I've been kinda fading out classes for a

Re: Importing local modules in C style

2015-06-26 Thread via Digitalmars-d-learn
On Thursday, 25 June 2015 at 13:57:35 UTC, Binarydepth wrote: I want to import a module from my local project in C style (#include local.h). You can theoretically do this with `mixin(import(local.d));`. This will more or less copy-paste the content of local.d into the current scope. You

Re: Struct vs. Class

2015-06-26 Thread Chris via Digitalmars-d-learn
On Friday, 26 June 2015 at 11:28:38 UTC, Daniel Kozák wrote: On Fri, 26 Jun 2015 11:11:15 + Chris via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: I have still some classes lying around in my code. As threading is becoming more and more of an issue, classes and OOP in

Re: Typed Message Passing between D Processes

2015-06-26 Thread Atila Neves via Digitalmars-d-learn
On Thursday, 25 June 2015 at 14:04:23 UTC, Per Nordlöw wrote: Is there an alternative to http://dlang.org/phobos/std_process.html#.pipe that can be used to do _typed_ _message_ _passing_ between two D processes with the same convenience as `send` and `receive` in std.concurrency ? Either