Re: segfault in invariant { assert(super); }

2015-12-21 Thread Steven Schveighoffer via Digitalmars-d-learn
On 12/19/15 11:01 PM, SimonN wrote: Hi, the following code compiles fine, then segfaults upon running. class Base { this(int) { } } class Derived : Base { this(int a) { super(a); } invariant() { assert (super); } } void main() {

Re: What other than a pointer can be converted implicitly to const(char)*?

2015-12-21 Thread Steven Schveighoffer via Digitalmars-d-learn
On 12/21/15 3:47 PM, anonymous wrote: On 21.12.2015 21:20, Steven Schveighoffer wrote: This seems like an incorrect feature then. Why wouldn't I want S to be treated like any other const(char)*? Seems like it's explicitly saying "treat this like a const(char)*" To my understanding, `alias

Socket - handling large numbers of incoming connections

2015-12-21 Thread Jakob Jenkov via Digitalmars-d-learn
What is the fastest / most scalable way to implement a server (using a Socket) which can handle large numbers of incoming connections? Like, at least 10K, but probably up to 1 million connections. More specifically: 1) How do I efficiently select the connections (client Socket instances)

Re: Socket - handling large numbers of incoming connections

2015-12-21 Thread Stefan via Digitalmars-d-learn
How about https://github.com/dcarp/asynchronous ? Asyncio Socket handling is sometimes quite nice. It's performance is okay for nearly no effort and the code looks clean. Details here: http://dcarp.github.io/asynchronous/asynchronous/streams/startServer.html vibe.d also offers a fiber based

Re: Socket - handling large numbers of incoming connections

2015-12-21 Thread Jakob Jenkov via Digitalmars-d-learn
On Monday, 21 December 2015 at 20:20:44 UTC, Stefan wrote: How about https://github.com/dcarp/asynchronous ? Asyncio Socket handling is sometimes quite nice. It's performance is okay for nearly no effort and the code looks clean. Details here:

Re: Socket - handling large numbers of incoming connections

2015-12-21 Thread Jakob Jenkov via Digitalmars-d-learn
My server uses "poll" for that. Okay, how does that work? How do I use "poll" in D? Link? Code example?

Re: What other than a pointer can be converted implicitly to const(char)*?

2015-12-21 Thread anonymous via Digitalmars-d-learn
On 21.12.2015 21:20, Steven Schveighoffer wrote: This seems like an incorrect feature then. Why wouldn't I want S to be treated like any other const(char)*? Seems like it's explicitly saying "treat this like a const(char)*" To my understanding, `alias this` means "is implicitly convertible to

Re: What other than a pointer can be converted implicitly to const(char)*?

2015-12-21 Thread Steven Schveighoffer via Digitalmars-d-learn
On 12/21/15 12:03 PM, anonymous wrote: On 21.12.2015 17:02, Shriramana Sharma wrote: https://github.com/D-Programming-Language/phobos/blob/master/std/conv.d#L878 The `static if` condition here says if something is a pointer and if it is implicitly convertible to const(char)*. The isPointer!

Re: Socket - handling large numbers of incoming connections

2015-12-21 Thread tcak via Digitalmars-d-learn
On Monday, 21 December 2015 at 20:53:14 UTC, Jakob Jenkov wrote: On Monday, 21 December 2015 at 20:20:44 UTC, Stefan wrote: How about https://github.com/dcarp/asynchronous ? Asyncio Socket handling is sometimes quite nice. It's performance is okay for nearly no effort and the code looks clean.

Re: Socket - handling large numbers of incoming connections

2015-12-21 Thread Daniel Kozák via Digitalmars-d-learn
V Mon, 21 Dec 2015 20:53:14 + Jakob Jenkov via Digitalmars-d-learn napsáno: > On Monday, 21 December 2015 at 20:20:44 UTC, Stefan wrote: > > How about https://github.com/dcarp/asynchronous ? Asyncio > > Socket handling is sometimes quite nice. It's

Re: Socket - handling large numbers of incoming connections

2015-12-21 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 21 December 2015 at 23:17:45 UTC, Daniel Kozák wrote: If you want to reinvent the wheel you can use It isn't really reinventing the wheel to just use an alternate library... it isn't like the bundled functions with the OS are hard to use and you really should understand how they

ndslice of an array structure member?

2015-12-21 Thread Jay Norwood via Digitalmars-d-learn
I'm trying to learn ndslice. It puzzles me why t3 compiles ok, but t4 causes a compiler error in the example below. Should I be able to slice a struct member that is an array? import std.stdio; import std.experimental.ndslice; import std.experimental.ndslice.iteration: transposed; struct

Re: ndslice and limits of debug info and autocompletion

2015-12-21 Thread Jack Stouffer via Digitalmars-d-learn
On Tuesday, 22 December 2015 at 00:21:16 UTC, Jay Norwood wrote: import std.experimental.ndslice.iteration: transposed; I don't use visualD so I can't help you there, but I wanted to point out that this import is unnecessary.

Re: ndslice of an array structure member?

2015-12-21 Thread Jack Stouffer via Digitalmars-d-learn
On Monday, 21 December 2015 at 23:59:07 UTC, Jay Norwood wrote: I'm trying to learn ndslice. It puzzles me why t3 compiles ok, but t4 causes a compiler error in the example below. Should I be able to slice a struct member that is an array? import std.stdio; import std.experimental.ndslice;

Re: Socket - handling large numbers of incoming connections

2015-12-21 Thread Adrian Matoga via Digitalmars-d-learn
On Monday, 21 December 2015 at 21:32:55 UTC, Jakob Jenkov wrote: My server uses "poll" for that. Okay, how does that work? How do I use "poll" in D? Link? Code example? The same as in C [1]. Just change #include to import core.sys.posix.poll; [1] http://linux.die.net/man/2/poll

ndslice and limits of debug info and autocompletion

2015-12-21 Thread Jay Norwood via Digitalmars-d-learn
I'm trying to determine if the debugger autocompletion would be useful in combination with ndslice. I find that using visualD I get offered no completion to select core_ctr or epu_ctr where epu_ctr is used in the writeln below. I take it this either means that there is some basic limitation

Re: ndslice and limits of debug info and autocompletion

2015-12-21 Thread Jay Norwood via Digitalmars-d-learn
The autocompletion doesn't work here to offer epu_ctr in the writeln statement either, so it doesn't seem to be a problem with number of subscripts. writeln(a1[0]. does offer epu_ctr for completion at the same place. import std.stdio; import std.experimental.ndslice; import

Re: C string to D without memory allocation?

2015-12-21 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, December 21, 2015 05:43:59 Jakob Ovrum via Digitalmars-d-learn wrote: > On Monday, 21 December 2015 at 05:41:31 UTC, Shriramana Sharma > wrote: > > Rikki Cattermole wrote: > > > >> string myCString = cast(string)ptr[0 .. strLen]; > > > > Thanks but does this require that one doesn't

Re: Make Simple Things Hard to Figure out

2015-12-21 Thread default0 via Digitalmars-d-learn
On Monday, 21 December 2015 at 16:20:18 UTC, Adam D. Ruppe wrote: On Monday, 21 December 2015 at 13:51:57 UTC, default0 wrote: The thing I was trying to do was dead simple: Receive a base64 encoded text via a query parameter. So when I read this, I thought you might have missed another

Re: Make Simple Things Hard to Figure out

2015-12-21 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 21 December 2015 at 18:02:55 UTC, default0 wrote: I don't have an IRC client set up since I rarely use that, plus an IRC is always kind of "out of the way". Just click this link: http://webchat.freenode.net/?channels=d type in a random name, click the captcha checkbox and go!

Re: C string to D without memory allocation?

2015-12-21 Thread Jakob Ovrum via Digitalmars-d-learn
On Monday, 21 December 2015 at 08:35:22 UTC, Jonathan M Davis wrote: There's also fromStringz that Jakob suggests using elsewhere in this thread, but that really just boils down to return cString ? cString[0 .. strlen(cString)] : null; So, using that over simply slicing is primarily for

Make Simple Things Hard to Figure out

2015-12-21 Thread default0 via Digitalmars-d-learn
Hi So today I tried setting up vibe.d and see how that all works out. Doing the initial setup was easy enough (dub is amazingly convenient!) and I had a "Hello World" server up and running in about 10 minutes. Sweet. After that, I started looking into vibes URLRouter - also easy enough,

Re: Template specialization using traits?

2015-12-21 Thread Shriramana Sharma via Digitalmars-d-learn
Thanks all for your replies. One question: Jonathan M Davis wrote: > Alternatively, you can use static if, though you're only dealing > with one template in that case. e.g. But if we wanted to deprecate one of the alternatives, then we necessary need to declare two templates with the same name

Re: C string to D without memory allocation?

2015-12-21 Thread Shriramana Sharma via Digitalmars-d-learn
Jonathan M Davis via Digitalmars-d-learn wrote: > If it isn't, all that means is that the > array's capacity will be 0, so it's going to have to reallocate So it's safe to return a string produced by fromStringz without having to worry that the user would append to it? Then why is it marked

Deimos recommendation still official?

2015-12-21 Thread Shriramana Sharma via Digitalmars-d-learn
http://dlang.org/spec/interfaceToC.html refers one to Deimos (https://github.com/D-Programming-Deimos) to look for existing bindings to C libraries. Is this recommendation still valid? I ask because less than one fourth of the repos there seem to have been active in this year 2015. Or is it

Re: C string to D without memory allocation?

2015-12-21 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, December 21, 2015 18:39:32 Rikki Cattermole via Digitalmars-d-learn wrote: > size_t strLen = ...; > char* ptr = ...; > > string myCString = cast(string)ptr[0 .. strLen]; > > I can't remember if it will include the null terminator or not, but if > it does just decrease strLen by 1.

Re: How is D doing?

2015-12-21 Thread ShinraTensei via Digitalmars-d-learn
Thank you for your insights. I've decided to stick with D. A friend of mine told me that my post might have sounded a bit trollish i assure you that was not the case. Also i never used any mailing lists so wasn't sure who to reply to so i replied to myself.

Re: How is D doing?

2015-12-21 Thread Rikki Cattermole via Digitalmars-d-learn
On 22/12/15 4:43 PM, ShinraTensei wrote: Thank you for your insights. I've decided to stick with D. A friend of mine told me that my post might have sounded a bit trollish i assure you that was not the case. No no it is fine for D.learn. It shows that you are willing to learn actually try

Re: Set color to a single point in Cairo

2015-12-21 Thread Basile B. via Digitalmars-d-learn
On Sunday, 20 December 2015 at 11:16:06 UTC, TheDGuy wrote: On Sunday, 20 December 2015 at 01:17:50 UTC, Basile B. wrote: On Saturday, 19 December 2015 at 14:16:23 UTC, TheDGuy wrote: is it possible to set the color of a single pixel with Cairo? Not like you would do with a classic canvas

Re: How is D doing?

2015-12-21 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 22 December 2015 at 03:30:32 UTC, ShinraTensei wrote: my question is weather the D is actually used anywhere D rox and is used by a lot of people. are there chances of it dying anytime soon. It can never die as long as we remember it...

How is D doing?

2015-12-21 Thread ShinraTensei via Digitalmars-d-learn
I recently noticed massive increase in new languages for a person to jump into(Nim, Rust, Go...etc) but my question is weather the D is actually used anywhere or are there chances of it dying anytime soon. So far I've tried a while bunch of languages and i do like D the most, since i am used

Re: ndslice of an array structure member?

2015-12-21 Thread Jay Norwood via Digitalmars-d-learn
On Tuesday, 22 December 2015 at 01:13:54 UTC, Jack Stouffer wrote: The problem is that t3 is slicing a1 which is a dynamic array, which is a range, while t4 is trying to slice a static array, which is not a range. ok, thanks. I lost track of the double meaning of static ... I normally think

Re: How is D doing?

2015-12-21 Thread Rikki Cattermole via Digitalmars-d-learn
On 22/12/15 4:30 PM, ShinraTensei wrote: I recently noticed massive increase in new languages for a person to jump into(Nim, Rust, Go...etc) but my question is weather the D is actually used anywhere or are there chances of it dying anytime soon. So far I've tried a while bunch of languages and

Re: How is D doing?

2015-12-21 Thread Ali Çehreli via Digitalmars-d-learn
On 12/21/2015 07:30 PM, ShinraTensei wrote: > I'm not looking into D for job opportunities. Even so, we may start hearing more and more D job openings. I've heard about yet another San Francisco startup where individual teams pick their own language and one of their teams uses D. (I don't

Template specialization using traits?

2015-12-21 Thread Shriramana Sharma via Digitalmars-d-learn
Hello. I want to define a template specialization using traits: import std.stdio, std.traits; void func(T)(T t) { writeln(1); } void func(T)(T t) if(isIntegral!T) { writeln(2); } void main() { func(1); } But I'm getting an error saying that the called function matches both. If it were a

Re: Template specialization using traits?

2015-12-21 Thread tcak via Digitalmars-d-learn
On Monday, 21 December 2015 at 11:12:10 UTC, Jonathan M Davis wrote: On Monday, 21 December 2015 at 11:07:16 UTC, Jonathan M Davis wrote: For your example to work with template constraints, the most straightforward solution would be void func(T)(T t) if(!isIntegral!T) { writeln(1); }

Re: Template specialization using traits?

2015-12-21 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, December 21, 2015 15:14:20 Shriramana Sharma via Digitalmars-d-learn wrote: > Hello. I want to define a template specialization using traits: > > import std.stdio, std.traits; > void func(T)(T t) { writeln(1); } > void func(T)(T t) if(isIntegral!T) { writeln(2); } > void main() > { >

Re: Template specialization using traits?

2015-12-21 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, 21 December 2015 at 11:07:16 UTC, Jonathan M Davis wrote: For your example to work with template constraints, the most straightforward solution would be void func(T)(T t) if(!isIntegral!T) { writeln(1); } void func(T)(T t) if(isIntegral!T) { writeln(2); }

Re: Template specialization using traits?

2015-12-21 Thread rumbu via Digitalmars-d-learn
On Monday, 21 December 2015 at 09:44:20 UTC, Shriramana Sharma wrote: Hello. I want to define a template specialization using traits: import std.stdio, std.traits; void func(T)(T t) { writeln(1); } void func(T)(T t) if(isIntegral!T) { writeln(2); } void main() { func(1); } But I'm getting

Re: Deimos recommendation still official?

2015-12-21 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, December 21, 2015 14:03:25 Shriramana Sharma via Digitalmars-d-learn wrote: > http://dlang.org/spec/interfaceToC.html refers one to Deimos > (https://github.com/D-Programming-Deimos) to look for existing bindings to C > libraries. Is this recommendation still valid? I ask because less

Re: ndslice and limits of debug info and autocompletion

2015-12-21 Thread Ilya via Digitalmars-d-learn
On Tuesday, 22 December 2015 at 00:21:16 UTC, Jay Norwood wrote: I'm trying to determine if the debugger autocompletion would be useful in combination with ndslice. I find that using visualD I get offered no completion to select core_ctr or epu_ctr where epu_ctr is used in the writeln below.

Re: Socket - handling large numbers of incoming connections

2015-12-21 Thread Daniel Kozak via Digitalmars-d-learn
V Mon, 21 Dec 2015 23:29:14 + "Adam D. Ruppe via Digitalmars-d-learn" napsáno: > On Monday, 21 December 2015 at 23:17:45 UTC, Daniel Kozák wrote: > > If you want to reinvent the wheel you can use > > It isn't really reinventing the wheel to just use an

Re: Make Simple Things Hard to Figure out

2015-12-21 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 21 December 2015 at 15:55:13 UTC, default0 wrote: Well if I post this as a question to SO and link it here, would you mind answering it? Maybe we should make this a general scheme: If someone has trouble learning something, just ask the question directly on SO and have someone

Re: Make Simple Things Hard to Figure out

2015-12-21 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 21 December 2015 at 13:51:57 UTC, default0 wrote: The thing I was trying to do was dead simple: Receive a base64 encoded text via a query parameter. So when I read this, I thought you might have missed another little fact... there's more than one base64. Yup, normal Base64

Re: Template specialization using traits?

2015-12-21 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, December 21, 2015 19:54:53 Shriramana Sharma via Digitalmars-d-learn wrote: > Thanks all for your replies. One question: > > Jonathan M Davis wrote: > > Alternatively, you can use static if, though you're only dealing > > with one template in that case. e.g. > > But if we wanted to

Re: Deimos recommendation still official?

2015-12-21 Thread Jacob Carlborg via Digitalmars-d-learn
On 2015-12-21 09:33, Shriramana Sharma wrote: http://dlang.org/spec/interfaceToC.html refers one to Deimos (https://github.com/D-Programming-Deimos) to look for existing bindings to C libraries. Is this recommendation still valid? I ask because less than one fourth of the repos there seem to

Re: Make Simple Things Hard to Figure out

2015-12-21 Thread thedeemon via Digitalmars-d-learn
On Monday, 21 December 2015 at 13:51:57 UTC, default0 wrote: As this isn't really a question for Learn I'm not sure if it fits here. This is more of a "This is how I went about trying to learn X. These are the problems I encountered. Ideas to improve?" but I guess I might as well post it here.

Re: Make Simple Things Hard to Figure out

2015-12-21 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 21 December 2015 at 15:49:14 UTC, thedeemon wrote: Out of curiosity I looked into "D Cookbook" to check if it contains your particular case but the only mention of Base64 there is about encoding some data into Base64, not the other way around. Hmm, yeah, I didn't want to have any

Re: Make Simple Things Hard to Figure out

2015-12-21 Thread default0 via Digitalmars-d-learn
On Monday, 21 December 2015 at 15:49:14 UTC, thedeemon wrote: On Monday, 21 December 2015 at 13:51:57 UTC, default0 wrote: As this isn't really a question for Learn I'm not sure if it fits here. This is more of a "This is how I went about trying to learn X. These are the problems I

Re: C string to D without memory allocation?

2015-12-21 Thread Marc Schütz via Digitalmars-d-learn
On Monday, 21 December 2015 at 09:46:58 UTC, Shriramana Sharma wrote: Jonathan M Davis via Digitalmars-d-learn wrote: If it isn't, all that means is that the array's capacity will be 0, so it's going to have to reallocate So it's safe to return a string produced by fromStringz without

What other than a pointer can be converted implicitly to const(char)*?

2015-12-21 Thread Shriramana Sharma via Digitalmars-d-learn
https://github.com/D-Programming-Language/phobos/blob/master/std/conv.d#L878 The `static if` condition here says if something is a pointer and if it is implicitly convertible to const(char)*. The isPointer! part seems superfluous. Is there something that is not a pointer yet implicitly

Re: What other than a pointer can be converted implicitly to const(char)*?

2015-12-21 Thread anonymous via Digitalmars-d-learn
On 21.12.2015 17:02, Shriramana Sharma wrote: https://github.com/D-Programming-Language/phobos/blob/master/std/conv.d#L878 The `static if` condition here says if something is a pointer and if it is implicitly convertible to const(char)*. The isPointer! part seems superfluous. Is there something