~ ?

2014-06-27 Thread pgtkda via Digitalmars-d-learn
What does this symbol mean in relation to D? ~

Enum type deduction inside templates is not working

2014-06-27 Thread Uranuz via Digitalmars-d-learn
Compiler can't deduce type for template struct Pair when using it with enum argument. There is an example import std.stdio; enum Category { first, second, third }; struct Pair(F, S) { F first; S second; this(F f, S s) { first = f;

Re: Enum type deduction inside templates is not working

2014-06-27 Thread pgtkda via Digitalmars-d-learn
On Friday, 27 June 2014 at 06:12:57 UTC, pgtkda wrote: How I could make this working without explicit specifying of types? sorry, i should read better

Re: Enum type deduction inside templates is not working

2014-06-27 Thread pgtkda via Digitalmars-d-learn
On Friday, 27 June 2014 at 06:04:20 UTC, Uranuz wrote: Compiler can't deduce type for template struct Pair when using it with enum argument. There is an example import std.stdio; enum Category { first, second, third }; struct Pair(F, S) { F first; S second;

Re: Enum type deduction inside templates is not working

2014-06-27 Thread Uranuz via Digitalmars-d-learn
On Friday, 27 June 2014 at 06:14:48 UTC, pgtkda wrote: On Friday, 27 June 2014 at 06:12:57 UTC, pgtkda wrote: How I could make this working without explicit specifying of types? sorry, i should read better Ok. Maybe it was discussed already somewhere, but I am not god in searching in

Re: ~ ?

2014-06-27 Thread Ali Çehreli via Digitalmars-d-learn
On 06/26/2014 10:58 PM, pgtkda wrote: What does this symbol mean in relation to D? ~ It can be used in two ways: 1) When used as a unary operator, it means bitwise complement: assert(~0xaa55aa55 == 0x55aa55aa); 2) When used as a binary operator, it means concatenation:

Re: Enum type deduction inside templates is not working

2014-06-27 Thread pgtkda via Digitalmars-d-learn
On Friday, 27 June 2014 at 06:21:11 UTC, Uranuz wrote: On Friday, 27 June 2014 at 06:14:48 UTC, pgtkda wrote: On Friday, 27 June 2014 at 06:12:57 UTC, pgtkda wrote: How I could make this working without explicit specifying of types? sorry, i should read better Ok. Maybe it was discussed

Re: ~ ?

2014-06-27 Thread pgtkda via Digitalmars-d-learn
On Friday, 27 June 2014 at 06:33:07 UTC, Ali Çehreli wrote: On 06/26/2014 10:58 PM, pgtkda wrote: What does this symbol mean in relation to D? ~ It can be used in two ways: 1) When used as a unary operator, it means bitwise complement: assert(~0xaa55aa55 == 0x55aa55aa); 2) When used

GC.calloc(), then what?

2014-06-27 Thread Ali Çehreli via Digitalmars-d-learn
1) After allocating memory by GC.calloc() to place objects on it, what else should one do? In what situations does one need to call addRoot() or addRange()? 2) Does the answer to the previous question differ for struct objects versus class objects? 3) Is there a difference between

Re: Enum type deduction inside templates is not working

2014-06-27 Thread Uranuz via Digitalmars-d-learn
I think, D is a typesafe language, therefore you can't use variables with no type declaration. One thing you can search for, are templates but even there you have to define a type: import std.stdio; enum Category : string { first = first} template Pair(T) { T t; T cat; }

Re: GC.calloc(), then what?

2014-06-27 Thread safety0ff via Digitalmars-d-learn
On Friday, 27 June 2014 at 07:03:28 UTC, Ali Çehreli wrote: 1) After allocating memory by GC.calloc() to place objects on it, what else should one do? Use std.conv.emplace. In what situations does one need to call addRoot() or addRange()? Add root creates an internal reference within the

Re: Enum type deduction inside templates is not working

2014-06-27 Thread Uranuz via Digitalmars-d-learn
Seems that I found answer myself. As far as I understand type inference is working only for template functions but not struct or class templates. This is why this not working and enum is not responsible for that. I don't know why I use D enough long but I did not remember this fact.

Re: GC.calloc(), then what?

2014-06-27 Thread safety0ff via Digitalmars-d-learn
I realize that my answer isn't completely clear in some cases, if you still have questions, ask away.

Re: Enum type deduction inside templates is not working

2014-06-27 Thread Uranuz via Digitalmars-d-learn
There is proposal exists for this topic http://wiki.dlang.org/DIP40

Re: GC.calloc(), then what?

2014-06-27 Thread Ali Çehreli via Digitalmars-d-learn
On 06/27/2014 12:53 AM, safety0ff wrote: I realize that my answer isn't completely clear in some cases, if you still have questions, ask away. Done! That's why we are here anyway. :p Ali

Re: GC.calloc(), then what?

2014-06-27 Thread Ali Çehreli via Digitalmars-d-learn
Thank you for your responses. I am partly enlightened. :p On 06/27/2014 12:34 AM, safety0ff wrote: On Friday, 27 June 2014 at 07:03:28 UTC, Ali Çehreli wrote: 1) After allocating memory by GC.calloc() to place objects on it, what else should one do? Use std.conv.emplace. That much I know.

Re: GC.calloc(), then what?

2014-06-27 Thread safety0ff via Digitalmars-d-learn
On Friday, 27 June 2014 at 08:17:07 UTC, Ali Çehreli wrote: Thank you for your responses. I am partly enlightened. :p I know you're a knowledgeable person in the D community, I may have stated many things you already knew, but I tried to answer the questions as-is. On 06/27/2014 12:34

Re: GC.calloc(), then what?

2014-06-27 Thread safety0ff via Digitalmars-d-learn
On Friday, 27 June 2014 at 08:17:07 UTC, Ali Çehreli wrote: So, the GC's default behavior is to scan the memory, necessitating clearing the contents? That seems to make GC.malloc() behave the same as GC.calloc() by default, doesn't it? Yes. compare:

Re: GC.calloc(), then what?

2014-06-27 Thread safety0ff via Digitalmars-d-learn
On Friday, 27 June 2014 at 09:20:53 UTC, safety0ff wrote: Yes. compare: https://github.com/D-Programming-Language/druntime/blob/master/src/gc/gc.d#L543 to: https://github.com/D-Programming-Language/druntime/blob/master/src/gc/gc.d#L419 Actually, I just realized that I was wrong in saying the

Re: GC.calloc(), then what?

2014-06-27 Thread eles via Digitalmars-d-learn
On Friday, 27 June 2014 at 08:17:07 UTC, Ali Çehreli wrote: Thank you for your responses. I am partly enlightened. :p On 06/27/2014 12:34 AM, safety0ff wrote: On Friday, 27 June 2014 at 07:03:28 UTC, Ali Çehreli wrote: But addRange doesn't seem to make sense for stdlib.malloc'ed memory,

What is best way to communicate between computer in local network ?

2014-06-27 Thread bioinfornatics via Digitalmars-d-learn
Hi, I have a linux network and i would like to know if they are a D library to communicate between computer efficiently. I do not know if that is better to use websocket and if they exists into dlang: - http://planet.jboss.org/post/rest_vs_websocket_comparison_and_benchmarks Thanks for

Re: ~ ?

2014-06-27 Thread Chris via Digitalmars-d-learn
On Friday, 27 June 2014 at 05:58:14 UTC, pgtkda wrote: What does this symbol mean in relation to D? ~ ~ D means it's about the best language I've come across so far.

Re: What is best way to communicate between computer in local network ?

2014-06-27 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 27 June 2014 at 12:51:45 UTC, bioinfornatics wrote: I do not know if that is better to use websocket and if they exists into dlang: you could use websocket in D but if you are talking between two separate D programs you can just use a regular socket

Re: What is best way to communicate between computer in local network ?

2014-06-27 Thread John Colvin via Digitalmars-d-learn
On Friday, 27 June 2014 at 12:51:45 UTC, bioinfornatics wrote: Hi, I have a linux network and i would like to know if they are a D library to communicate between computer efficiently. I do not know if that is better to use websocket and if they exists into dlang: -

Re: What is best way to communicate between computer in local network ?

2014-06-27 Thread bioinfornatics via Digitalmars-d-learn
On Friday, 27 June 2014 at 13:03:20 UTC, John Colvin wrote: On Friday, 27 June 2014 at 12:51:45 UTC, bioinfornatics wrote: Hi, I have a linux network and i would like to know if they are a D library to communicate between computer efficiently. I do not know if that is better to use

Re: What is best way to communicate between computer in local network ?

2014-06-27 Thread bioinfornatics via Digitalmars-d-learn
On Friday, 27 June 2014 at 13:02:55 UTC, Adam D. Ruppe wrote: On Friday, 27 June 2014 at 12:51:45 UTC, bioinfornatics wrote: I do not know if that is better to use websocket and if they exists into dlang: you could use websocket in D but if you are talking between two separate D programs you

Re: Enum type deduction inside templates is not working

2014-06-27 Thread H. S. Teoh via Digitalmars-d-learn
On Fri, Jun 27, 2014 at 06:04:18AM +, Uranuz via Digitalmars-d-learn wrote: Compiler can't deduce type for template struct Pair when using it with enum argument. There is an example import std.stdio; enum Category { first, second, third }; struct Pair(F, S) { F first;

Re: Enum type deduction inside templates is not working

2014-06-27 Thread Chris Nicholson-Sauls via Digitalmars-d-learn
On Friday, 27 June 2014 at 07:43:27 UTC, Uranuz wrote: I don't know why I use D enough long but I did not remember this fact. Sometimes we get spoiled by all the amazing/nifty things that do work, and expect comparable things like this to Just Work. To be honest, at first I didn't see any

Re: Enum type deduction inside templates is not working

2014-06-27 Thread Chris Nicholson-Sauls via Digitalmars-d-learn
On Friday, 27 June 2014 at 14:27:46 UTC, H. S. Teoh via Digitalmars-d-learn wrote: Try this: Get out of my head!

Re: import except one?

2014-06-27 Thread Chris Nicholson-Sauls via Digitalmars-d-learn
On Friday, 27 June 2014 at 05:26:09 UTC, Puming wrote: On Thursday, 26 June 2014 at 08:02:24 UTC, bearophile wrote: Puming: I'm using scriptlike, which imports everything from std.process for convienience, but I also need to import another module, which contains a class `Config`, it

Regex problem

2014-06-27 Thread seany via Digitalmars-d-learn
Cosider this: ulong regexChk(string haystack, string needle) { // haystack and needle are okey auto r = regex(needle, g); auto m = match(haystack, r); // up to here is all fine return m.hit().count(); } I want to count the numbers needles is mathced in haystack But I get

Re: Regex problem

2014-06-27 Thread H. S. Teoh via Digitalmars-d-learn
On Fri, Jun 27, 2014 at 03:59:47PM +, seany via Digitalmars-d-learn wrote: [...] core.exception.AssertError@std.regex(5587): Assertion failure ./niarbyl(_d_assertm+0x26) [0x4e6c26] ./niarbyl() [0x4f45be] ./niarbyl(pure nothrow @property @trusted immutable(char)[]

The D2 dictionary chalenge.

2014-06-27 Thread Basile Burg via Digitalmars-d-learn
Try to make a faster one than http://dpaste.dzfl.pl/aa2ad03cb0dd Post your reply here, existing entries must be included.

Re: GC.calloc(), then what?

2014-06-27 Thread Sean Kelly via Digitalmars-d-learn
On Friday, 27 June 2014 at 07:34:55 UTC, safety0ff wrote: On Friday, 27 June 2014 at 07:03:28 UTC, Ali Çehreli wrote: 1) After allocating memory by GC.calloc() to place objects on it, what else should one do? Use std.conv.emplace. And possibly set BlkInfo flags to indicate whether the block

Re: GC.calloc(), then what?

2014-06-27 Thread Ali Çehreli via Digitalmars-d-learn
On 06/27/2014 01:49 AM, safety0ff wrote: On Friday, 27 June 2014 at 08:17:07 UTC, Ali Çehreli wrote: Thank you for your responses. I am partly enlightened. :p I know you're a knowledgeable person in the D community, I may have stated many things you already knew, but I tried to answer the