Re: wrapSocket for socket_t? As wrapFile for FILE*

2016-02-14 Thread Beginner-8 via Digitalmars-d-learn
On Sunday, 14 February 2016 at 08:19:16 UTC, Ali Çehreli wrote: On 02/14/2016 12:03 AM, Beginner-8 wrote: Uh, wait! Forgot about that Socket calls .close() in its dtor Try duplicating the socket handle before handing it over to Socket (not compiled nor tested): import core.sys.posix.unistd;

Re: Installing 32 bit libcurl.so.4 on Ubuntu

2016-02-14 Thread hanifnoor via Digitalmars-d-learn
I'm not 100% sure it's included, but I think so. __ NOOR

Re: Reserving capacity in associative arrays

2016-02-14 Thread Jon D via Digitalmars-d-learn
On Monday, 15 February 2016 at 05:29:23 UTC, sigod wrote: On Monday, 15 February 2016 at 03:22:44 UTC, Jon D wrote: Is there a way to reserve capacity in associative arrays? [snip] Maybe try using this: http://code.dlang.org/packages/aammm Thanks, I wasn't aware of this package. I'll give it

Re: Reserving capacity in associative arrays

2016-02-14 Thread sigod via Digitalmars-d-learn
On Monday, 15 February 2016 at 03:22:44 UTC, Jon D wrote: Is there a way to reserve capacity in associative arrays? In some programs I've been writing I've been getting reasonable performance up to about 10 million entries, but beyond that performance is impacted considerably (say, 30 million o

Re: nanosecond time

2016-02-14 Thread Saurabh Das via Digitalmars-d-learn
On Saturday, 13 February 2016 at 19:24:44 UTC, ishwar wrote: I am stumped on need finding interval between two events in a program execution in nanoseconds. Any sample code will be appreciated (along with imports needed to make it work): - time in nanoseconds-now - do-some processing - time in

Reserving capacity in associative arrays

2016-02-14 Thread Jon D via Digitalmars-d-learn
Is there a way to reserve capacity in associative arrays? In some programs I've been writing I've been getting reasonable performance up to about 10 million entries, but beyond that performance is impacted considerably (say, 30 million or 50 million entries). GC stats (via the "--DRT-gcopt=prof

Re: D Book page 402 Concurrency FAIL

2016-02-14 Thread Mike Parker via Digitalmars-d-learn
On Monday, 15 February 2016 at 00:58:54 UTC, Brother Bill wrote: On Sunday, 14 February 2016 at 23:39:33 UTC, cym13 wrote: On Sunday, 14 February 2016 at 22:54:36 UTC, Brother Bill wrote: In "The D Programming Language", page 402, the toy program fails. [...] Can't reproduce with DMD 2.0.70

Re: joiner: How to iterate over immutable ranges?

2016-02-14 Thread Mike Parker via Digitalmars-d-learn
On Sunday, 14 February 2016 at 19:32:31 UTC, Bastiaan Veelo wrote: Thanks. I didn't know that iterating a range means mutating its contents. I still don't quite get it, and it is probably because I don't fully understand ranges. I think what confuses me the most is their analogy to containers.

Re: joiner: How to iterate over immutable ranges?

2016-02-14 Thread Ali Çehreli via Digitalmars-d-learn
On 02/14/2016 11:32 AM, Bastiaan Veelo wrote: > Thanks. I didn't know that iterating a range means mutating its > contents. That's not the case: Just like an iterator, a range must maintain some state to know which item is next. What needs to be mutated is that iteration state. > I still don

Re: Implicit conversion from string to custom type?

2016-02-14 Thread Ali Çehreli via Digitalmars-d-learn
On 02/14/2016 03:43 PM, Tofu Ninja wrote: So I wrote a simple ref counted string type because using the built in strings without the GC is extremely painful. It there any way I can get strings to implicitly convert to my custom string type? No, D does not support such implicit conversions. st

Re: D Book page 402 Concurrency FAIL

2016-02-14 Thread Brother Bill via Digitalmars-d-learn
On Sunday, 14 February 2016 at 23:39:33 UTC, cym13 wrote: On Sunday, 14 February 2016 at 22:54:36 UTC, Brother Bill wrote: In "The D Programming Language", page 402, the toy program fails. [...] Can't reproduce with DMD 2.0.70, LDC 0.16.1 or GDC 5.3.0 on Linux x86_64. The code seems to work

Implicit conversion from string to custom type?

2016-02-14 Thread Tofu Ninja via Digitalmars-d-learn
So I wrote a simple ref counted string type because using the built in strings without the GC is extremely painful. It there any way I can get strings to implicitly convert to my custom string type? Some way to make this work... struct rstring {...} void fun(rstring s) {...} ... fun("hello wo

Re: D Book page 402 Concurrency FAIL

2016-02-14 Thread cym13 via Digitalmars-d-learn
On Sunday, 14 February 2016 at 22:54:36 UTC, Brother Bill wrote: In "The D Programming Language", page 402, the toy program fails. [...] Can't reproduce with DMD 2.0.70, LDC 0.16.1 or GDC 5.3.0 on Linux x86_64. The code seems to work as intended.

D Book page 402 Concurrency FAIL

2016-02-14 Thread Brother Bill via Digitalmars-d-learn
In "The D Programming Language", page 402, the toy program fails. The first fail is that enforce() needs: import std.exception; The second fail is that when debugging, in Visual Studio 2015 Community Edition, it fails with this error: First-change exception: std.format.FormatException Unterm

Re: joiner: How to iterate over immutable ranges?

2016-02-14 Thread Bastiaan Veelo via Digitalmars-d-learn
On Sunday, 14 February 2016 at 18:28:11 UTC, Jonathan M Davis wrote: An immutable range fundamentally does not work. The same goes with const. In fact, a type that's immutable is going to fail isInputRange precisely because it can't possibly function as one. While empty and front may be calla

Re: joiner: How to iterate over immutable ranges?

2016-02-14 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, February 14, 2016 15:24:39 Bastiaan Veelo via Digitalmars-d-learn wrote: > Hi, > > I am having trouble getting the iteration methods in > std.algorithm.iteration to work on immutable data: > > > import std.algorithm.iteration; > > import std.stdio; > > > > void main() > > { > > stri

Re: Singleton, alias to self?

2016-02-14 Thread tcak via Digitalmars-d-learn
On Sunday, 14 February 2016 at 12:56:51 UTC, Vladde Nordholm wrote: I'm not sure of how to use alias efficiently, so I want to know if I could somehow do this (psuedo-code) class Singleton { //So instead of calling `Singleton.getSingleton()` you just call `Singleton` alias this = getSingl

joiner: How to iterate over immutable ranges?

2016-02-14 Thread Bastiaan Veelo via Digitalmars-d-learn
Hi, I am having trouble getting the iteration methods in std.algorithm.iteration to work on immutable data: import std.algorithm.iteration; import std.stdio; void main() { string[][] cycles; cycles ~= ["one", "two"]; cycles ~= ["three", "four"]; foreach (numbe

Re: Singleton, alias to self?

2016-02-14 Thread Guillaume Piolat via Digitalmars-d-learn
On Sunday, 14 February 2016 at 13:23:28 UTC, Guillaume Piolat wrote: On Sunday, 14 February 2016 at 12:56:51 UTC, Vladde Nordholm wrote: I'm not sure of how to use alias efficiently, so I want to know if I could somehow do this (psuedo-code) class Singleton { //So instead of calling `Singlet

Re: Singleton, alias to self?

2016-02-14 Thread Guillaume Piolat via Digitalmars-d-learn
On Sunday, 14 February 2016 at 12:56:51 UTC, Vladde Nordholm wrote: I'm not sure of how to use alias efficiently, so I want to know if I could somehow do this (psuedo-code) class Singleton { //So instead of calling `Singleton.getSingleton()` you just call `Singleton` alias this = getSingl

Singleton, alias to self?

2016-02-14 Thread Vladde Nordholm via Digitalmars-d-learn
I'm not sure of how to use alias efficiently, so I want to know if I could somehow do this (psuedo-code) class Singleton { //So instead of calling `Singleton.getSingleton()` you just call `Singleton` alias this = getSingleon() //code for singleton... } Thanks in advance, vladde

Re: Is this a good singleton?

2016-02-14 Thread Vladde Nordholm via Digitalmars-d-learn
On Sunday, 14 February 2016 at 07:16:54 UTC, Russel Winder wrote: On Sat, 2016-02-13 at 18:58 +, Vladde Nordholm via Digitalmars-d- learn wrote: [...] Following the ACCU consensus: there is never, ever a good Singleton or reason to contemplate using one. Obviously though there are some

Photoshop programming

2016-02-14 Thread Patience via Digitalmars-d-learn
Photoshop has the ability to be controlled by scripts and programming languages. For example, C# can be used to access photoshop by adding the appropriate reference and using directives. I believe it is COM based but I am not totally sure. I've tried reading the docs but it's not making much s

Re: wrapSocket for socket_t? As wrapFile for FILE*

2016-02-14 Thread Ali Çehreli via Digitalmars-d-learn
On 02/14/2016 12:03 AM, Beginner-8 wrote: Uh, wait! Forgot about that Socket calls .close() in its dtor Try duplicating the socket handle before handing it over to Socket (not compiled nor tested): import core.sys.posix.unistd; Socket(dup(myHandle)) I think socket handles are duplicata

Re: wrapSocket for socket_t? As wrapFile for FILE*

2016-02-14 Thread Beginner-8 via Digitalmars-d-learn
Uh, wait! Forgot about that Socket calls .close() in its dtor

Re: wrapSocket for socket_t? As wrapFile for FILE*

2016-02-14 Thread Beginner-8 via Digitalmars-d-learn
On Sunday, 14 February 2016 at 07:33:11 UTC, Ali Çehreli wrote: Maybe another option is to duplicate the socket handle Sure! Nevertheless, it is need method for socket_t duplication. Something like: class Socket { ... static Socket dup(socket_t) ... } before giving it to Socket but I am f