Re: Checking if a port is listening

2016-03-18 Thread Timothee Cour via Digitalmars-d-learn
see also: https://github.com/rejectedsoftware/vibe.d/issues/1431 api to find an available port On Fri, Mar 18, 2016 at 2:50 AM, Marc Schütz via Digitalmars-d-learn < digitalmars-d-learn@puremagic.com> wrote: > Looking at an strace of nmap, it seems it opens a bunch of sockets, puts > them into

Re: size_t index=-1;

2016-03-18 Thread Marc Schütz via Digitalmars-d-learn
On Thursday, 17 March 2016 at 17:09:46 UTC, Steven Schveighoffer wrote: On 3/16/16 6:37 PM, Mathias Lang wrote: On Wednesday, 16 March 2016 at 21:49:05 UTC, Steven Schveighoffer wrote: No, please don't. Assigning a signed value to an unsigned (and vice versa) is very useful, and there is no goo

Re: Obtaining argument names in (variadic) functions

2016-03-18 Thread Edwin van Leeuwen via Digitalmars-d-learn
On Thursday, 17 March 2016 at 13:53:00 UTC, JR wrote: Interesting, any idea if it is possible to do assignment within template.. Either: printVars!(int abc=5,string def="58")(); or something like printVars!("abc","def",ghi)(5,"58"); What would the use-cases for those be? I don't think the

Re: size_t index=-1;

2016-03-18 Thread Steven Schveighoffer via Digitalmars-d-learn
On 3/16/16 6:37 PM, Mathias Lang wrote: On Wednesday, 16 March 2016 at 21:49:05 UTC, Steven Schveighoffer wrote: No, please don't. Assigning a signed value to an unsigned (and vice versa) is very useful, and there is no good reason to break this. I'm not talking about removing it completely. T

Re: size_t index=-1;

2016-03-18 Thread Mathias Lang via Digitalmars-d-learn
On Wednesday, 16 March 2016 at 18:40:56 UTC, Laeeth Isharc wrote: should it be a compiler warning to assign a negative literal to an unsigned without a cast ? yes it should. https://issues.dlang.org/show_bug.cgi?id=3468

immutable array in constructor

2016-03-18 Thread Jeff Thompson via Digitalmars-d-learn
In the following code, I explicitly declare array as immutable. But it compiles with the error shown below in the comment. The array object is declared immutable, so how can the compiler say it is a mutable object? In summary, how to pass an immutable array to an immutable constructor? class

Re: Solution to "statement is not reachable" depending on template variables?

2016-03-18 Thread Johan Engelen via Digitalmars-d-learn
On Wednesday, 16 March 2016 at 11:22:02 UTC, rikki cattermole wrote: Change those static if's to just plain old ifs. But then this wouldn't compile, would it? ``` static if(__traits(compiles, __traits(getMember, a, "b"))) { return a.b; } ``` (real code, I am not making this up) Imagine tho

Whitch can replace std::bind/boost::bind ?

2016-03-18 Thread Dsby via Digitalmars-d-learn
foreach (i ; 0..4) { auto th = new Thread(delegate(){listRun(i);});//this is erro _thread[i]= th; th.start(); } void listRun(int i) { writeln("i = ", i); // the value is not(0,1,2,3), it all is 2. } I want to know how to use it like std::bind.

Re: Solution to "statement is not reachable" depending on template variables?

2016-03-18 Thread tsbockman via Digitalmars-d-learn
On Wednesday, 16 March 2016 at 11:18:36 UTC, Johan Engelen wrote: Hi all, I've found discussions, but not an actual "recommended" solution for the problem of "statement is not reachable" warnings in templates with early returns... "statement is not reachable" is fundamentally broken in D fo

Re: string and char[] in Phobos

2016-03-18 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, March 18, 2016 08:24:24 Puming via Digitalmars-d-learn wrote: > Hi, > > I saw from the forum that functions with string like arguments > better use `in char[]` instead of `string` type, because then it > can accept both string and char[] types. > > But recently when actually using D, I f

Re: size_t index=-1;

2016-03-18 Thread tsbockman via Digitalmars-d-learn
On Friday, 18 March 2016 at 14:51:34 UTC, Steven Schveighoffer wrote: Note, I have made these mistakes myself, and I understand what you are asking for and why you are asking for it. But these are bugs. The user is telling the compiler to do one thing, and expecting it to do something else. It'

Re: size_t index=-1;

2016-03-18 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, March 18, 2016 23:48:32 tsbockman via Digitalmars-d-learn wrote: > I'm basically saying, "because information is lost when casting > between signed and unsigned, all such casts should be explicit". See. Here's the fundamental disagreement. _No_ information is lost when converting betwee

Re: size_t index=-1;

2016-03-18 Thread Anonymouse via Digitalmars-d-learn
On Wednesday, 16 March 2016 at 21:49:05 UTC, Steven Schveighoffer wrote: No, please don't. Assigning a signed value to an unsigned (and vice versa) is very useful, and there is no good reason to break this. -Steve I agree, but implicitly allowing for comparisons between the two allows for e

size_t index=-1;

2016-03-18 Thread Laeeth Isharc via Digitalmars-d-learn
should it be a compiler warning to assign a negative literal to an unsigned without a cast ?

Re: Obtaining argument names in (variadic) functions

2016-03-18 Thread JR via Digitalmars-d-learn
On Wednesday, 16 March 2016 at 20:43:09 UTC, jkpl wrote: I try to anticipate the reason why you want this. [...] I use something *kinda* sort of similar in my toy project to print all fields of a struct, for debugging purposes when stuff goes wrong. Getting the names of the member variables i

Re: immutable array in constructor

2016-03-18 Thread Rene Zwanenburg via Digitalmars-d-learn
On Thursday, 17 March 2016 at 10:11:43 UTC, Jeff Thompson wrote: This is a simplified example from a larger class I have where I need an immutable constructor. This is because I need to construct an object an pass it to other functions which take an immutable object. So, how to keep an immutabl

Re: size_t index=-1;

2016-03-18 Thread tsbockman via Digitalmars-d-learn
On Friday, 18 March 2016 at 05:20:35 UTC, Ola Fosheim Grøstaf wrote: Only providing modular arithmetics is a significant language design flaw, but as long as all integers are defined to be modular then there is no fundamental semantic difference either. `ulong.max` and `-1L` are fundamentally