Re: Getting "this" to work similar to "self" in Python

2015-07-22 Thread Jacob Carlborg via Digitalmars-d-learn
On 2015-07-23 00:22, nurfz wrote: I think you got overly complicated answers. I guess I'm confused as to why the D code isn't acting similar to the Python code in the sense that you would expect "this" to reference the "speed" property of the current instance and not statically reference the pa

Re: C bindings: typedef struct conflicts with method

2015-07-22 Thread Jacob Carlborg via Digitalmars-d-learn
On 2015-07-23 03:57, Mike Parker wrote: In your case, rd_kafka_metadata is the name of the struct, but in C instances would need to be declared like so: struct rd_kafka_metadata instance; Since the struct is declared directly in the typedef, is the struct name actually available? -- /Jacob

Connection to server socket "Invalid argument"

2015-07-22 Thread VlasovRoman via Digitalmars-d-learn
I have some code. //client.d import std.stdio; import std.socket; import std.conv; void main() { Socket client = new TcpSocket(AddressFamily.INET); autoaddr = new InternetAddress("localhost", 2021); autoaddrServer = new InternetAddress("localhost", 2017);

Re: Getting "this" to work similar to "self" in Python

2015-07-22 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, July 22, 2015 23:19:35 nurfz via Digitalmars-d-learn wrote: > Hmm, is there a specific reason aside from the encapsulation > violation? It seems needlessly complicated. If you have > someone/something that has direct access to your source code, > isn't a getter/setter the least of y

Re: C bindings: typedef struct conflicts with method

2015-07-22 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 21 July 2015 at 05:53:26 UTC, yawniek wrote: i tried to automagically create bindings for librdkafka (https://github.com/edenhill/librdkafka) with dstep. now the code contains typedefs structs with the same name as methods: ``` typedef struct rd_kafka_metadata { int

Re: How to get *32mscoff libraries for phobos?

2015-07-22 Thread Mike Parker via Digitalmars-d-learn
On Thursday, 23 July 2015 at 01:39:05 UTC, Mike Parker wrote: post at [1] where Rainer shared the relevant bits of a batch Gah, hate it when I forget the links. [1] http://forum.dlang.org/post/m456t5$2jc4$1...@digitalmars.com

Re: How to get *32mscoff libraries for phobos?

2015-07-22 Thread Mike Parker via Digitalmars-d-learn
On Wednesday, 22 July 2015 at 23:39:46 UTC, Jonathan M Davis wrote: On Wednesday, July 22, 2015 20:27:35 Taylor Hillegeist via Digitalmars-d-learn wrote: I have tried to build this and failed miserably. I have some questions? What make do you use? digital mars, gnu. what tools do you need? is

Re: How to get *32mscoff libraries for phobos?

2015-07-22 Thread Mike Parker via Digitalmars-d-learn
On Wednesday, 22 July 2015 at 20:27:37 UTC, Taylor Hillegeist wrote: I have tried to build this and failed miserably. I have some questions? What make do you use? digital mars, gnu. what tools do you need? is it possible? I also failed to build zlib32coff.lib make[2]: *** No rule to make targe

Re: How to get *32mscoff libraries for phobos?

2015-07-22 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, July 22, 2015 20:27:35 Taylor Hillegeist via Digitalmars-d-learn wrote: > I have tried to build this and failed miserably. I have some > questions? > What make do you use? digital mars, gnu. what tools do you need? > is it possible? I also failed to build zlib32coff.lib > > make[2]:

Re: Getting "this" to work similar to "self" in Python

2015-07-22 Thread nurfz via Digitalmars-d-learn
Hmm, is there a specific reason aside from the encapsulation violation? It seems needlessly complicated. If you have someone/something that has direct access to your source code, isn't a getter/setter the least of your concerns? Does the @property decorator incur a large runtime cost?

Re: Getting "this" to work similar to "self" in Python

2015-07-22 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, July 22, 2015 22:22:00 nurfz via Digitalmars-d-learn wrote: > How could I get this D code to work similar to this Python code? > > So, here is the D code: > > import std.stdio; > > class Vehicle { > int speed; > void printSpeed() { > writeln(th

Re: Getting "this" to work similar to "self" in Python

2015-07-22 Thread John Colvin via Digitalmars-d-learn
On Wednesday, 22 July 2015 at 22:22:02 UTC, nurfz wrote: How could I get this D code to work similar to this Python code? So, here is the D code: import std.stdio; class Vehicle { int speed; void printSpeed() { writeln(this.speed); } } class

Getting "this" to work similar to "self" in Python

2015-07-22 Thread nurfz via Digitalmars-d-learn
How could I get this D code to work similar to this Python code? So, here is the D code: import std.stdio; class Vehicle { int speed; void printSpeed() { writeln(this.speed); } } class Airplane: Vehicle { int speed = 100; } i

How to get *32mscoff libraries for phobos?

2015-07-22 Thread Taylor Hillegeist via Digitalmars-d-learn
I have tried to build this and failed miserably. I have some questions? What make do you use? digital mars, gnu. what tools do you need? is it possible? I also failed to build zlib32coff.lib make[2]: *** No rule to make target `zlib32mscoff.lib'. Stop. I could say more but it probably wouldn'

Re: Sending an immutable object to a thread

2015-07-22 Thread rsw0x via Digitalmars-d-learn
On Wednesday, 22 July 2015 at 17:17:17 UTC, Frank Pagliughi wrote: On Wednesday, 22 July 2015 at 09:04:49 UTC, Marc Schütz wrote: But as long as the original pointer is still on the stack, that one _will_ keep the object alive. It is only a problem if all pointers to a GC managed object are s

Re: Sending an immutable object to a thread

2015-07-22 Thread Frank Pagliughi via Digitalmars-d-learn
On Wednesday, 22 July 2015 at 09:04:49 UTC, Marc Schütz wrote: But as long as the original pointer is still on the stack, that one _will_ keep the object alive. It is only a problem if all pointers to a GC managed object are stored in places the GC isn't informed about. Sorry, I have gotten

Re: Thread pools

2015-07-22 Thread via Digitalmars-d-learn
On Wednesday, 22 July 2015 at 16:16:36 UTC, John Colvin wrote: On Wednesday, 22 July 2015 at 15:51:23 UTC, Chris wrote: On Wednesday, 22 July 2015 at 15:41:06 UTC, Alex Parrill wrote: [...] Thanks. I'm dealing with "nested" threads at the moment. main { spawn(thread1) { // Does some

Re: Thread pools

2015-07-22 Thread John Colvin via Digitalmars-d-learn
On Wednesday, 22 July 2015 at 15:51:23 UTC, Chris wrote: On Wednesday, 22 July 2015 at 15:41:06 UTC, Alex Parrill wrote: On Wednesday, 22 July 2015 at 14:28:48 UTC, Chris wrote: What would be the best way to manage different threads (spawned via std.concurrency), e.g. to tell them to stop at o

Re: Thread pools

2015-07-22 Thread Chris via Digitalmars-d-learn
On Wednesday, 22 July 2015 at 15:41:06 UTC, Alex Parrill wrote: On Wednesday, 22 July 2015 at 14:28:48 UTC, Chris wrote: What would be the best way to manage different threads (spawned via std.concurrency), e.g. to tell them to stop at once, once a new command comes in? A thread pool? How would

Re: Thread pools

2015-07-22 Thread Alex Parrill via Digitalmars-d-learn
On Wednesday, 22 July 2015 at 14:28:48 UTC, Chris wrote: What would be the best way to manage different threads (spawned via std.concurrency), e.g. to tell them to stop at once, once a new command comes in? A thread pool? How would that look like in D? I feel my knowledge of D threads is still

Re: Sending an immutable object to a thread

2015-07-22 Thread rsw0x via Digitalmars-d-learn
On Wednesday, 22 July 2015 at 09:04:49 UTC, Marc Schütz wrote: On Tuesday, 21 July 2015 at 21:50:35 UTC, rsw0x wrote: On Tuesday, 21 July 2015 at 21:44:07 UTC, rsw0x wrote: [...] addendum: http://dlang.org/garbage.html [...] [...] I believe this implies that it would *not* keep the obj

Thread pools

2015-07-22 Thread Chris via Digitalmars-d-learn
What would be the best way to manage different threads (spawned via std.concurrency), e.g. to tell them to stop at once, once a new command comes in? A thread pool? How would that look like in D? I feel my knowledge of D threads is still a bit limited.

Re: Measuring Execution time

2015-07-22 Thread Clayton via Digitalmars-d-learn
On Wednesday, 22 July 2015 at 09:32:15 UTC, John Colvin wrote: On Wednesday, 22 July 2015 at 09:23:36 UTC, Clayton wrote: [...] The normal way of doing this would be using std.datetime.StopWatch: StopWatch sw; sw.start(); algorithm(); long exec_ms = sw.peek().msecs; Much a

std.net.curl and PATCH

2015-07-22 Thread Andrea Fontana via Digitalmars-d-learn
It seems that PATCH http method is missing from std.net.curl http methods. No way to use it?

Re: Measuring Execution time

2015-07-22 Thread John Colvin via Digitalmars-d-learn
On Wednesday, 22 July 2015 at 09:23:36 UTC, Clayton wrote: How does one represent Duration in only Micro-seconds, or milliseconds. Trying to measure the execution time of an algorithm and I get "4 ms, 619 μs, and 8 hnsecs" , I want to sum all these and get total hnsecs or μs . I would also a

Measuring Execution time

2015-07-22 Thread Clayton via Digitalmars-d-learn
How does one represent Duration in only Micro-seconds, or milliseconds. Trying to measure the execution time of an algorithm and I get "4 ms, 619 μs, and 8 hnsecs" , I want to sum all these and get total hnsecs or μs . I would also appreciate advise on whether this is the best way to measur

Re: Sending an immutable object to a thread

2015-07-22 Thread via Digitalmars-d-learn
On Tuesday, 21 July 2015 at 21:50:35 UTC, rsw0x wrote: On Tuesday, 21 July 2015 at 21:44:07 UTC, rsw0x wrote: On Sunday, 19 July 2015 at 17:12:07 UTC, rsw0x wrote: [...] wow, I don't even remember posting this. This is (mostly) wrong, but I'm unsure if a pointer to another pointer on the st