Re: Utf8 to Utf32 cast cost

2015-06-08 Thread Daniel Kozák via Digitalmars-d-learn
On Mon, 08 Jun 2015 10:51:53 + weaselcat via Digitalmars-d-learn wrote: > On Monday, 8 June 2015 at 10:49:59 UTC, Ilya Yaroshenko wrote: > > On Monday, 8 June 2015 at 10:42:00 UTC, Kadir Erdem Demir wrote: > >> I want to use my char array with awesome, cool std.algorithm > >> functions. Sin

Re: Utf8 to Utf32 cast cost

2015-06-08 Thread Daniel Kozák via Digitalmars-d-learn
On Mon, 08 Jun 2015 10:41:59 + Kadir Erdem Demir via Digitalmars-d-learn wrote: > I want to use my char array with awesome, cool std.algorithm > functions. Since many of this algorithms requires like slicing > etc.. I prefer to create my string with Utf32 chars. But by > default all strin

Re: Utf8 to Utf32 cast cost

2015-06-08 Thread Daniel Kozák via Digitalmars-d-learn
On Mon, 08 Jun 2015 10:41:59 + Kadir Erdem Demir via Digitalmars-d-learn wrote: > I want to use my char array with awesome, cool std.algorithm > functions. Since many of this algorithms requires like slicing > etc.. I prefer to create my string with Utf32 chars. But by > default all strin

Re: What does program do when array is returned from function?

2015-06-04 Thread Daniel Kozák via Digitalmars-d-learn
On Thu, 04 Jun 2015 07:03:30 + tcak via Digitalmars-d-learn wrote: > [code] > char[] test(){ > auto t = new char[5]; > > return t; > } > [/code] > > Is the test function returning just a pointer from heap or does > copy operation? > this is same as: auto t = new char[](5) it wi

Re: How to implement immutable ring buffer?

2015-05-27 Thread Daniel Kozák via Digitalmars-d-learn
On Wed, 27 May 2015 09:20:52 + drug via Digitalmars-d-learn wrote: > Could somebody share his thoughts on the subject? > Would it be efficient? Is it possible to avoid memory copying to > provide immutability? To avoid cache missing ring buffer should be > like array, not list, so it's possi

Re: problem with gc?

2015-05-27 Thread Daniel Kozák via Digitalmars-d-learn
On Wed, 27 May 2015 05:48:11 + zhmt via Digitalmars-d-learn wrote: > I am writing a echoclient, as below: > > Ptr!Conn conn = connect("127.0.0.1",8881); > ubyte[100] buf; > for(int i=0; i { > scope string str = format("%s",i); > conn.write((cast(ubyte*)str.ptr)[0..str.length]);

Re: Weird result of getsockopt

2015-05-24 Thread Daniel Kozak via Digitalmars-d-learn
On Sunday, 24 May 2015 at 21:13:02 UTC, Daniel Kozak wrote: On Sunday, 24 May 2015 at 21:11:34 UTC, Daniel Kozak wrote: On Sunday, 24 May 2015 at 16:51:44 UTC, CodeSun wrote: Hello guys, Today, I found a weird problem when I was learning to enable SO_KEEPALIVE for a specific socket. I use

Re: Weird result of getsockopt

2015-05-24 Thread Daniel Kozak via Digitalmars-d-learn
On Sunday, 24 May 2015 at 21:11:34 UTC, Daniel Kozak wrote: On Sunday, 24 May 2015 at 16:51:44 UTC, CodeSun wrote: Hello guys, Today, I found a weird problem when I was learning to enable SO_KEEPALIVE for a specific socket. I use setsockopt to enable keepalive firstly, and then use getsockopt

Re: Weird result of getsockopt

2015-05-24 Thread Daniel Kozak via Digitalmars-d-learn
On Sunday, 24 May 2015 at 16:51:44 UTC, CodeSun wrote: Hello guys, Today, I found a weird problem when I was learning to enable SO_KEEPALIVE for a specific socket. I use setsockopt to enable keepalive firstly, and then use getsockopt to show if it is enabled correctly. My code snippet is lis

Re: Template type deduction and specialization

2015-05-21 Thread Daniel Kozák via Digitalmars-d-learn
On Thu, 21 May 2015 09:58:16 -0400 Steven Schveighoffer via Digitalmars-d-learn wrote: > On 5/21/15 9:14 AM, Daniel Kozak wrote: > > On Thursday, 21 May 2015 at 13:12:36 UTC, Daniel Kozák wrote: > >> > >> On Thu, 21 May 2015 08:54:54 -0400 > >> Steven S

Re: Template type deduction and specialization

2015-05-21 Thread Daniel Kozak via Digitalmars-d-learn
On Thursday, 21 May 2015 at 13:12:36 UTC, Daniel Kozák wrote: On Thu, 21 May 2015 08:54:54 -0400 Steven Schveighoffer via Digitalmars-d-learn wrote: On 5/21/15 2:35 AM, Daniel Kozák via Digitalmars-d-learn wrote: > > On Wed, 20 May 2015 17:23:05 -0700 > Ali Çehreli via Digitalmar

Re: Template type deduction and specialization

2015-05-21 Thread Daniel Kozák via Digitalmars-d-learn
On Thu, 21 May 2015 08:54:54 -0400 Steven Schveighoffer via Digitalmars-d-learn wrote: > On 5/21/15 2:35 AM, Daniel Kozák via Digitalmars-d-learn wrote: > > > > On Wed, 20 May 2015 17:23:05 -0700 > > Ali Çehreli via Digitalmars-d-learn > > wrote: > > > &g

Re: Template type deduction and specialization

2015-05-20 Thread Daniel Kozák via Digitalmars-d-learn
On Wed, 20 May 2015 17:23:05 -0700 Ali Çehreli via Digitalmars-d-learn wrote: > On 05/20/2015 04:10 PM, Mike Parker wrote: > > On Wednesday, 20 May 2015 at 13:46:22 UTC, Daniel Kozák wrote: > >> DOC say `may not have` not `must not have` ;-) > >> > > > >

Re: Template type deduction and specialization

2015-05-20 Thread Daniel Kozák via Digitalmars-d-learn
DOC say `may not have` not `must not have` ;-) On Wed, 20 May 2015 13:24:22 + Mike Parker via Digitalmars-d-learn wrote: > On Wednesday, 20 May 2015 at 09:35:43 UTC, Daniel Kozak wrote: > > > DOCS: http://dlang.org/template.html#function-templates > > says: Func

Re: Template type deduction and specialization

2015-05-20 Thread Daniel Kozak via Digitalmars-d-learn
On Wednesday, 20 May 2015 at 09:35:48 UTC, Jonathan M Davis wrote: Well, if printVal!(int*)(px); prints 100, then that's a bug. It should print the address. In fact, it should be _impossible_ for the second overload of printVal to ever be instantiated IMHO thats not true, it should print

Re: Template type deduction and specialization

2015-05-20 Thread Daniel Kozak via Digitalmars-d-learn
On Wednesday, 20 May 2015 at 07:27:53 UTC, jklp wrote: --- import std.stdio; void printVal(T)(T t) { writeln(t); } void printVal(T: T)(T* t) { writeln(*t); } void main() { int x = 100; printVal(x); int* px = &x; printVal(px); } --- here it's se

Re: Template type deduction and specialization

2015-05-20 Thread Daniel Kozak via Digitalmars-d-learn
On Wednesday, 20 May 2015 at 09:24:28 UTC, Daniel Kozák wrote: On Wed, 20 May 2015 06:31:11 + Mike Parker via Digitalmars-d-learn wrote: I don't understand why this behaves as it does. Given the following two templates: ``` void printVal(T)(T t) { writeln(t); } void pri

Re: Template type deduction and specialization

2015-05-20 Thread Daniel Kozák via Digitalmars-d-learn
On Wed, 20 May 2015 06:31:11 + Mike Parker via Digitalmars-d-learn wrote: > I don't understand why this behaves as it does. Given the > following two templates: > > ``` > void printVal(T)(T t) { > writeln(t); > } > void printVal(T : T*)(T* t) { > writeln(*t); > } > ``` > > I f

Re: ICE?

2015-05-19 Thread Daniel Kozak via Digitalmars-d-learn
On Sunday, 17 May 2015 at 09:25:33 UTC, Namespace wrote: Is this error an ICE? I think so, because I see the internal filename, but I'm not sure. Error: e2ir: cannot cast malloc(length * 8u) of type void* to type char[] https://github.com/D-Programming-Language/dmd/pull/4667

Re: ICE?

2015-05-17 Thread Daniel Kozak via Digitalmars-d-learn
On Sun, 17 May 2015 10:36:33 + Namespace via Digitalmars-d-learn wrote: > On Sunday, 17 May 2015 at 09:59:41 UTC, Daniel Kozak wrote: > > > > On Sun, 17 May 2015 09:33:27 + > > Namespace via Digitalmars-d-learn > > wrote: > > > >> On

Re: ICE?

2015-05-17 Thread Daniel Kozak via Digitalmars-d-learn
On Sun, 17 May 2015 10:17:42 + anonymous via Digitalmars-d-learn wrote: > On Sunday, 17 May 2015 at 10:09:11 UTC, Daniel Kozak wrote: > > On Sunday, 17 May 2015 at 09:25:33 UTC, Namespace wrote: > [...] > >> Error: e2ir: cannot cast malloc(length * 8u) of type voi

Re: ICE?

2015-05-17 Thread Daniel Kozak via Digitalmars-d-learn
On Sunday, 17 May 2015 at 09:59:41 UTC, Daniel Kozak wrote: On Sun, 17 May 2015 09:33:27 + Namespace via Digitalmars-d-learn wrote: On Sunday, 17 May 2015 at 09:30:16 UTC, Gary Willoughby wrote: > On Sunday, 17 May 2015 at 09:25:33 UTC, Namespace wrote: >> Is this error an ICE

Re: How to create a mutable array of strings?

2015-05-17 Thread Daniel Kozak via Digitalmars-d-learn
On Sunday, 17 May 2015 at 09:57:05 UTC, Daniel Kozak wrote: On Sun, 17 May 2015 09:39:21 + Dennis Ritchie via Digitalmars-d-learn wrote: I remembered code Ali Çereli. It really helped: http://forum.dlang.org/thread/ulhtlyxxclihaseef...@forum.dlang.org#post-mihl6m:241che:241

Re: ICE?

2015-05-17 Thread Daniel Kozak via Digitalmars-d-learn
On Sunday, 17 May 2015 at 09:25:33 UTC, Namespace wrote: Is this error an ICE? I think so, because I see the internal filename, but I'm not sure. Error: e2ir: cannot cast malloc(length * 8u) of type void* to type char[] I would say this is not an ICE just normal error message.

Re: ICE?

2015-05-17 Thread Daniel Kozak via Digitalmars-d-learn
On Sun, 17 May 2015 09:33:27 + Namespace via Digitalmars-d-learn wrote: > On Sunday, 17 May 2015 at 09:30:16 UTC, Gary Willoughby wrote: > > On Sunday, 17 May 2015 at 09:25:33 UTC, Namespace wrote: > >> Is this error an ICE? I think so, because I see the internal > >> filename, but I'm not

Re: How to create a mutable array of strings?

2015-05-17 Thread Daniel Kozak via Digitalmars-d-learn
On Sun, 17 May 2015 09:39:21 + Dennis Ritchie via Digitalmars-d-learn wrote: > I remembered code Ali Çereli. It really helped: > http://forum.dlang.org/thread/ulhtlyxxclihaseef...@forum.dlang.org#post-mihl6m:241che:241:40digitalmars.com > > - > import std.stdio, std.traits, std.range, s

Re: How to create a mutable array of strings?

2015-05-17 Thread Daniel Kozak via Digitalmars-d-learn
On Sunday, 17 May 2015 at 09:20:17 UTC, Dennis Ritchie wrote: On Sunday, 17 May 2015 at 09:18:15 UTC, Daniel Kozak wrote: auto s = cast(char[][])["foo", "bar"]; Thanks. This version I was completely satisfied. So maybe this one would be ok with you too :) auto s =

Re: How to create a mutable array of strings?

2015-05-17 Thread Daniel Kozak via Digitalmars-d-learn
On Sunday, 17 May 2015 at 09:21:58 UTC, Marc Schütz wrote: On Sunday, 17 May 2015 at 09:18:15 UTC, Daniel Kozak wrote: On Sun, 17 May 2015 09:06:38 + Dennis Ritchie via Digitalmars-d-learn wrote: Hi, It seems to me, or D do not create mutable array of strings? How to create a mutable

Re: How to create a mutable array of strings?

2015-05-17 Thread Daniel Kozak via Digitalmars-d-learn
On Sunday, 17 May 2015 at 09:18:15 UTC, Daniel Kozak wrote: On Sun, 17 May 2015 09:06:38 + Dennis Ritchie via Digitalmars-d-learn wrote: Hi, It seems to me, or D do not create mutable array of strings? How to create a mutable equivalent of a string array? - string[] s = [&quo

Re: How to create a mutable array of strings?

2015-05-17 Thread Daniel Kozak via Digitalmars-d-learn
On Sun, 17 May 2015 09:06:38 + Dennis Ritchie via Digitalmars-d-learn wrote: > Hi, > It seems to me, or D do not create mutable array of strings? > > How to create a mutable equivalent of a string array? > > - > string[] s = ["foo", "bar"]; > // s[1][1] = 't'; // immutable expression s

Re: How to create a mutable array of strings?

2015-05-17 Thread Daniel Kozak via Digitalmars-d-learn
On Sun, 17 May 2015 09:06:38 + Dennis Ritchie via Digitalmars-d-learn wrote: > Hi, > It seems to me, or D do not create mutable array of strings? > > How to create a mutable equivalent of a string array? > > - > string[] s = ["foo", "bar"]; > // s[1][1] = 't'; // immutable expression s

Re: What wrong?

2015-05-15 Thread Daniel Kozak via Digitalmars-d-learn
On Friday, 15 May 2015 at 09:20:32 UTC, Gary Willoughby wrote: On Friday, 15 May 2015 at 07:51:29 UTC, thedeemon wrote: On Saturday, 2 May 2015 at 02:51:52 UTC, Fyodor Ustinov wrote: Simple code: http://pastebin.com/raw.php?i=7jVeMFXQ What I'm doing wrong? Try using class instead of struct.

Re: Extreme memory usage when `synchronized( this )` is used

2015-05-11 Thread Daniel Kozak via Digitalmars-d-learn
On Monday, 11 May 2015 at 10:24:57 UTC, Daniel Kozák wrote: On Mon, 11 May 2015 09:40:28 + tcak via Digitalmars-d-learn wrote: On Monday, 11 May 2015 at 09:20:50 UTC, Daniel Kozák wrote: > > On Mon, 11 May 2015 09:09:07 + > tcak via Digitalmars-d-learn > wrote: &

Re: Extreme memory usage when `synchronized( this )` is used

2015-05-11 Thread Daniel Kozák via Digitalmars-d-learn
On Mon, 11 May 2015 09:40:28 + tcak via Digitalmars-d-learn wrote: > On Monday, 11 May 2015 at 09:20:50 UTC, Daniel Kozák wrote: > > > > On Mon, 11 May 2015 09:09:07 + > > tcak via Digitalmars-d-learn > > wrote: > > > > > > I think sync

Re: Extreme memory usage when `synchronized( this )` is used

2015-05-11 Thread Daniel Kozák via Digitalmars-d-learn
On Mon, 11 May 2015 09:40:28 + tcak via Digitalmars-d-learn wrote: > On Monday, 11 May 2015 at 09:20:50 UTC, Daniel Kozák wrote: > > > > On Mon, 11 May 2015 09:09:07 + > > tcak via Digitalmars-d-learn > > wrote: > > > > > > I think sync

Re: Extreme memory usage when `synchronized( this )` is used

2015-05-11 Thread Daniel Kozák via Digitalmars-d-learn
On Mon, 11 May 2015 09:09:07 + tcak via Digitalmars-d-learn wrote: > [code] > import std.stdio; > > class Connection{ > private void other() shared{} > > public void close() shared{ > synchronized( this ){ > other(); > } >

Re: Static function template

2015-05-07 Thread Daniel Kozak via Digitalmars-d-learn
On Thursday, 7 May 2015 at 11:18:17 UTC, Daniel Kozak wrote: On Thursday, 7 May 2015 at 11:15:02 UTC, Daniel Kozak wrote: On Thursday, 7 May 2015 at 11:08:50 UTC, Daniel Kozák wrote: On Thu, 07 May 2015 10:46:19 + Lemonfiend via Digitalmars-d-learn wrote: On Thursday, 7 May 2015 at

Re: Static function template

2015-05-07 Thread Daniel Kozak via Digitalmars-d-learn
On Thursday, 7 May 2015 at 10:19:44 UTC, Lemonfiend wrote: Is it not possible to have a static function template with the same name as the non-static version? struct S { int i; auto foo(T)(int j) { i=j; } static auto foo(T)(int j) { S s; s.foo!T(j);

Re: Static function template

2015-05-07 Thread Daniel Kozak via Digitalmars-d-learn
On Thursday, 7 May 2015 at 11:08:50 UTC, Daniel Kozák wrote: On Thu, 07 May 2015 10:46:19 + Lemonfiend via Digitalmars-d-learn wrote: On Thursday, 7 May 2015 at 10:43:28 UTC, Daniel Kozak wrote: > On Thursday, 7 May 2015 at 10:39:09 UTC, Daniel Kozák wrote: >> >> On Thu,

Re: Static function template

2015-05-07 Thread Daniel Kozak via Digitalmars-d-learn
On Thursday, 7 May 2015 at 11:15:02 UTC, Daniel Kozak wrote: On Thursday, 7 May 2015 at 11:08:50 UTC, Daniel Kozák wrote: On Thu, 07 May 2015 10:46:19 + Lemonfiend via Digitalmars-d-learn wrote: On Thursday, 7 May 2015 at 10:43:28 UTC, Daniel Kozak wrote: > On Thursday, 7 May 2015

Re: Static function template

2015-05-07 Thread Daniel Kozák via Digitalmars-d-learn
On Thu, 07 May 2015 10:46:19 + Lemonfiend via Digitalmars-d-learn wrote: > On Thursday, 7 May 2015 at 10:43:28 UTC, Daniel Kozak wrote: > > On Thursday, 7 May 2015 at 10:39:09 UTC, Daniel Kozák wrote: > >> > >> On Thu, 07 May 2015 10:33:44 + > >> V

Re: Static function template

2015-05-07 Thread Daniel Kozak via Digitalmars-d-learn
On Thursday, 7 May 2015 at 10:39:09 UTC, Daniel Kozák wrote: On Thu, 07 May 2015 10:33:44 + Vadim Lopatin via Digitalmars-d-learn wrote: struct S { int i; auto foo2(T)(int j) { i=j; } static S foo(T)(int j) { S s; s.foo2!T(j

Re: Static function template

2015-05-07 Thread Daniel Kozák via Digitalmars-d-learn
On Thu, 07 May 2015 10:33:44 + Vadim Lopatin via Digitalmars-d-learn wrote: > struct S > { > int i; > > auto foo2(T)(int j) { > i=j; > } > > static S foo(T)(int j) { > S s; > s.foo2!T(j); > return s; > } > } > > void main() > {

Re: Static function template

2015-05-07 Thread Daniel Kozák via Digitalmars-d-learn
On Thu, 07 May 2015 10:19:42 + Lemonfiend via Digitalmars-d-learn wrote: > Is it not possible to have a static function template with the > same name as the non-static version? > > struct S > { > int i; > > auto foo(T)(int j) { > i=j; > } > > static auto foo(

Re: Static function template

2015-05-07 Thread Daniel Kozák via Digitalmars-d-learn
On Thu, 07 May 2015 10:19:42 + Lemonfiend via Digitalmars-d-learn wrote: > Is it not possible to have a static function template with the > same name as the non-static version? > > struct S > { > int i; > > auto foo(T)(int j) { > i=j; > } > > static auto foo(

Re: Printing an std.container.Array

2015-04-16 Thread Daniel Kozák via Digitalmars-d-learn
On Thu, 16 Apr 2015 20:18:40 + Panke via Digitalmars-d-learn wrote: > > > > Yep, but problem is almost no one expect this, or know this. We > > definitely > > should do better. > > How? Improve doc at least. But it would be fine to have something like dump function (equivalent of php var_

Re: Printing an std.container.Array

2015-04-16 Thread Daniel Kozak via Digitalmars-d-learn
On Thu, 16 Apr 2015 13:05:48 -0700 "H. S. Teoh via Digitalmars-d-learn" wrote: > On Thu, Apr 16, 2015 at 07:55:52PM +, Bayan Rafeh via Digitalmars-d-learn > wrote: > > Executing this code: > > > > import std.container.array; > > import std.stdio; > > > > > > int main() { > > writeln(A

Re: Printing an std.container.Array

2015-04-16 Thread Daniel Kozak via Digitalmars-d-learn
On Thu, 16 Apr 2015 19:55:52 + Bayan Rafeh via Digitalmars-d-learn wrote: > Executing this code: > > import std.container.array; > import std.stdio; > > > int main() { > writeln(Array!int([1, 2])); > return 0; > } > > outputs the following: > > Array!int(RefCounted!(Payload,

Re: Converting void* to D array

2015-04-14 Thread Daniel Kozak via Digitalmars-d-learn
On Wednesday, 15 April 2015 at 04:43:39 UTC, Daniel Kozák wrote: On Wed, 15 Apr 2015 04:24:20 + Craig Dillabaugh via Digitalmars-d-learn wrote: Hi. I want to call a C library function that returns a data buffer as a void*. How do I convert the resulting void* into something I can

Re: Converting void* to D array

2015-04-14 Thread Daniel Kozák via Digitalmars-d-learn
On Wed, 15 Apr 2015 04:24:20 + Craig Dillabaugh via Digitalmars-d-learn wrote: > Hi. > I want to call a C library function that returns a data buffer as > a void*. How do I convert the resulting void* into something I > can process in D? > > //I have the following function from the GDAL

Re: Converting void* to D array

2015-04-14 Thread Daniel Kozák via Digitalmars-d-learn
On Wed, 15 Apr 2015 04:24:20 + Craig Dillabaugh via Digitalmars-d-learn wrote: > Hi. > I want to call a C library function that returns a data buffer as > a void*. How do I convert the resulting void* into something I > can process in D? > > //I have the following function from the GDAL

Re: Parameter is null by default. No value is given. Code says it is not null.

2015-04-09 Thread Daniel Kozák via Digitalmars-d-learn
On Thu, 09 Apr 2015 11:04:47 -0400 Steven Schveighoffer via Digitalmars-d-learn wrote: > > Note that the "bad" behavior (which was just fixed BTW) is > if(somearr), which used to mean if(somearr.ptr), and now it's a > compiler error. > > -Steve Yeah, because of this I must change almost 1k lin

Re: Parameter is null by default. No value is given. Code says it is not null.

2015-04-09 Thread Daniel Kozák via Digitalmars-d-learn
On Thu, 09 Apr 2015 11:04:47 -0400 Steven Schveighoffer via Digitalmars-d-learn wrote: > > Note that the "bad" behavior (which was just fixed BTW) is > if(somearr), which used to mean if(somearr.ptr), and now it's a > compiler error. > > -Steve Yeah, because of this I must change almost 1k lin

Re: Parameter is null by default. No value is given. Code says it is not null.

2015-04-09 Thread Daniel Kozak via Digitalmars-d-learn
On Thursday, 9 April 2015 at 14:42:33 UTC, Daniel Kozak wrote: On Thursday, 9 April 2015 at 14:30:07 UTC, Daniel Kozak wrote: On Thursday, 9 April 2015 at 14:25:56 UTC, Daniel Kozak wrote: On Thursday, 9 April 2015 at 14:16:00 UTC, tcak wrote: By the way, I am using "DMD64 D Compiler v2.

Re: Parameter is null by default. No value is given. Code says it is not null.

2015-04-09 Thread Daniel Kozak via Digitalmars-d-learn
On Thursday, 9 April 2015 at 14:30:07 UTC, Daniel Kozak wrote: On Thursday, 9 April 2015 at 14:25:56 UTC, Daniel Kozak wrote: On Thursday, 9 April 2015 at 14:16:00 UTC, tcak wrote: By the way, I am using "DMD64 D Compiler v2.067.0" on Ubuntu 14.04. I have Archlinux DMD64 D Compile

Re: Parameter is null by default. No value is given. Code says it is not null.

2015-04-09 Thread Daniel Kozak via Digitalmars-d-learn
On Thursday, 9 April 2015 at 14:25:56 UTC, Daniel Kozak wrote: On Thursday, 9 April 2015 at 14:16:00 UTC, tcak wrote: By the way, I am using "DMD64 D Compiler v2.067.0" on Ubuntu 14.04. I have Archlinux DMD64 D Compiler v2.067.0 and it works OK for me. WOW rdmd app.d(without par

Re: Parameter is null by default. No value is given. Code says it is not null.

2015-04-09 Thread Daniel Kozak via Digitalmars-d-learn
On Thursday, 9 April 2015 at 14:16:00 UTC, tcak wrote: By the way, I am using "DMD64 D Compiler v2.067.0" on Ubuntu 14.04. I have Archlinux DMD64 D Compiler v2.067.0 and it works OK for me.

Re: Parameter is null by default. No value is given. Code says it is not null.

2015-04-09 Thread Daniel Kozák via Digitalmars-d-learn
On Thu, 09 Apr 2015 11:45:30 + tcak via Digitalmars-d-learn wrote: > I have written a function as follows: > > public bool setCookie( > string name, > string value, > long maxAgeInSeconds = long.min, > string expiresOnGMTDate=null, > string path=null, > s

Re: alias this of non-public member

2015-04-07 Thread Daniel Kozak via Digitalmars-d-learn
On Tuesday, 7 April 2015 at 17:43:08 UTC, Daniel Kozak wrote: On Tuesday, 7 April 2015 at 17:21:09 UTC, Daniel Kozak wrote: On Tue, 07 Apr 2015 16:40:29 + via Digitalmars-d-learn wrote: Hi! Excuse me if this is obvious, but I can't recall coming across anything similar and a

Re: alias this of non-public member

2015-04-07 Thread Daniel Kozak via Digitalmars-d-learn
On Tuesday, 7 April 2015 at 17:21:09 UTC, Daniel Kozak wrote: On Tue, 07 Apr 2015 16:40:29 + via Digitalmars-d-learn wrote: Hi! Excuse me if this is obvious, but I can't recall coming across anything similar and a quick search returns nothing relevant: struct Foo { } s

Re: alias this of non-public member

2015-04-07 Thread Daniel Kozak via Digitalmars-d-learn
On Tue, 07 Apr 2015 16:40:29 + via Digitalmars-d-learn wrote: > Hi! > > Excuse me if this is obvious, but I can't recall coming across > anything similar and a quick search returns nothing relevant: > > struct Foo { > } > > struct FooWrapper { >alias x_ this; >private Foo* x_; //

Re: final methods by default

2015-03-20 Thread Daniel Kozak via Digitalmars-d-learn
On Fri, 20 Mar 2015 16:27:04 -0700 Jonathan M Davis via Digitalmars-d-learn wrote: > On Friday, March 20, 2015 23:53:14 Daniel Kozak via Digitalmars-d-learn wrote: > > > > On Fri, 20 Mar 2015 22:11:51 + > > weaselcat via Digitalmars-d-learn wrote: > > > >

Re: final methods by default

2015-03-20 Thread Daniel Kozak via Digitalmars-d-learn
On Fri, 20 Mar 2015 22:11:51 + weaselcat via Digitalmars-d-learn wrote: > On Friday, 20 March 2015 at 14:25:22 UTC, ref2401 wrote: > > Why aren't methods of class final by default? > > history > > use final class, it should devirtualize all methods. > see: https://github.com/D-Programming-

Re: variadic mixin - the right tool for the job?

2015-03-18 Thread Daniel Kozák via Digitalmars-d-learn
On Wed, 18 Mar 2015 15:35:03 +0100 "Robert M. Münch via Digitalmars-d-learn" wrote: > Hi, can something like this (I borrowed the C pre-processor idea) be > done with variadic mixins? > > #define log(variadic-arg) sys-log("%s:%s" + variadic-arg[0], > __FILE__, __LINE__, variadic-arg[1..$]); >

Re: Do strings with enum allocate at usage point?

2015-03-18 Thread Daniel Kozák via Digitalmars-d-learn
On Tue, 17 Mar 2015 11:25:00 -0700 Ali Çehreli via Digitalmars-d-learn wrote: > On 03/17/2015 11:21 AM, "岩倉 澪" wrote: > > I often hear it advised to avoid using enum with arrays because they > > will allocate at the usage point, but does this also apply to > > strings? strings are arrays, so nai

Re: moving from c++ to D is easy?

2015-03-12 Thread Daniel Kozák via Digitalmars-d-learn
On Thu, 12 Mar 2015 13:35:18 + ayush via Digitalmars-d-learn wrote: > On Thursday, 12 March 2015 at 13:13:40 UTC, Dennis Ritchie wrote: > > On Thursday, 12 March 2015 at 13:01:31 UTC, ayush wrote: > >> Is D a lot like c++? > > > > Enough. > > > >> So should i focus on one or learn both toget

Re: How to find the cause of crash?

2015-03-11 Thread Daniel Kozák via Digitalmars-d-learn
On Wed, 11 Mar 2015 10:05:39 + zhmt via Digitalmars-d-learn wrote: > I want to know how to locate the position of crashing in dlang? > > for example: there is stack dump in c, exception stack in java, > they could help to locate the root of problems. > D has these too, you just need to

Re: How to find the cause of crash?

2015-03-11 Thread Daniel Kozák via Digitalmars-d-learn
On Wed, 11 Mar 2015 10:05:39 + zhmt via Digitalmars-d-learn wrote: > I want to know how to locate the position of crashing in dlang? > > for example: there is stack dump in c, exception stack in java, > they could help to locate the root of problems. > D has these too, you just need to

Re: Dividing D Module between multiple files

2015-02-17 Thread Daniel Kozák via Digitalmars-d-learn
On Wed, 18 Feb 2015 07:23:24 + Muahmmad Adel via Digitalmars-d-learn wrote: > I have searched online and I found no way for dividing D Module > between multiple files. > > While other languages move to making classes distributed on > multiple files (like C#'s partial classes), D is moving

Re: Compilation with dub + dmd: out of memory

2015-02-10 Thread Daniel Kozák via Digitalmars-d-learn
V Tue, 10 Feb 2015 11:44:09 + Vlasov Roman via Digitalmars-d-learn napsáno: > On Tuesday, 10 February 2015 at 11:32:32 UTC, bearophile wrote: > > Vlasov Roman: > > > >> I have the quite computer with 2 GB RAM. At compilation with > >> dub and dmd of small project this pair eating about 1.4~1

Re: static class vs. static struct

2015-01-27 Thread Daniel Kozak via Digitalmars-d-learn
On Tuesday, 27 January 2015 at 09:36:49 UTC, Daniel Kozak wrote: On Tuesday, 27 January 2015 at 09:01:39 UTC, ref2401 wrote: For several times I've met struct(or static struct) usage in Phobos for singleton pattern implementation. Unfortunately now i can remember only core.runtime.Runtim

Re: static class vs. static struct

2015-01-27 Thread Daniel Kozak via Digitalmars-d-learn
On Tuesday, 27 January 2015 at 09:01:39 UTC, ref2401 wrote: For several times I've met struct(or static struct) usage in Phobos for singleton pattern implementation. Unfortunately now i can remember only core.runtime.Runtime. So I've got a question. Why do Phobos guys use struct or static struc

Re: Virtual functions and inheritance

2015-01-27 Thread Daniel Kozák via Digitalmars-d-learn
V Tue, 27 Jan 2015 04:38:57 + David Monagle via Digitalmars-d-learn napsáno: > Hi guys, > > I'm a former C++ developer and really enjoying working with D > now. I have a question that I hope some of you may be able to > answer. > > class Parent { >@property string typeName() { >

Re: Why can't functions and struct types have the same name?

2015-01-26 Thread Daniel Kozak via Digitalmars-d-learn
On Monday, 26 January 2015 at 11:15:26 UTC, Joakim wrote: Right now, any attempt to have symbols with the same name errors out, regardless of how they're used. This caused a problem for me because I'm trying to use a third-party C library that defines a struct type called "socket" and my code

Re: Unicode exception raise when replacing underscore with space

2015-01-13 Thread Daniel Kozak via Digitalmars-d-learn
On Tuesday, 13 January 2015 at 20:30:16 UTC, Nordlöw wrote: On Tuesday, 13 January 2015 at 13:01:56 UTC, Daniel Kozák via Digitalmars-d-learn wrote: What do I need to do/add to avoid auto-decoding here? std.array.replace(x, `_`, ` `); Thanks! What about adding See alsos in the docs that

Re: Endless static this call when used a thread in it

2015-01-13 Thread Daniel Kozak via Digitalmars-d-learn
On Tuesday, 13 January 2015 at 14:02:45 UTC, Daniel Kozák via Digitalmars-d-learn wrote: V Tue, 13 Jan 2015 13:56:05 + tcak via Digitalmars-d-learn napsáno: On Tuesday, 13 January 2015 at 13:53:11 UTC, tcak wrote: > I have written the following code: > &g

Re: Endless static this call when used a thread in it

2015-01-13 Thread Daniel Kozák via Digitalmars-d-learn
V Tue, 13 Jan 2015 13:56:05 + tcak via Digitalmars-d-learn napsáno: > On Tuesday, 13 January 2015 at 13:53:11 UTC, tcak wrote: > > I have written the following code: > > > > test.d > > == > > import core.thread; > > import std.stdio; > > > > void threadFunc(){ > >

Re: Endless static this call when used a thread in it

2015-01-13 Thread Daniel Kozák via Digitalmars-d-learn
V Tue, 13 Jan 2015 13:53:09 + tcak via Digitalmars-d-learn napsáno: > I have written the following code: > > test.d > == > import core.thread; > import std.stdio; > > void threadFunc(){ > writeln("Thread func"); > } > > public static this(){ > auto t

Re: Unicode exception raise when replacing underscore with space

2015-01-13 Thread Daniel Kozák via Digitalmars-d-learn
V Tue, 13 Jan 2015 12:32:15 + "Nordlöw" via Digitalmars-d-learn napsáno: > I get > > core.exception.UnicodeException@src/rt/util/utf.d(290): > > in a call to > > std.string.tr(x, `_`, ` `) > > for a badly encode string x. Is it really needed to do > auto-decoding here? > > Isn

Re: Accessing class with module name as Java's

2015-01-13 Thread Daniel Kozák via Digitalmars-d-learn
V Tue, 13 Jan 2015 10:58:27 + tcak via Digitalmars-d-learn napsáno: > > > > Ah, I just re-read your OP. Your already at this point :) > > Since everybody has understood the problem, and nobody could have > come up with a solution yet, my idea is that: > > HttpSocketConnectionRequest.d > ==

Re: casting SysTime to ubyte[]

2015-01-12 Thread Daniel Kozák via Digitalmars-d-learn
V Mon, 12 Jan 2015 13:59:27 + Laeeth Isharc via Digitalmars-d-learn napsáno: > import std.datetime; > import std.stdio; > import std.conv; > > void main(string[] arg) > { > auto a=Clock.currTime(); > auto b=cast(ubyte[])a; > writefln("%s",b); > } > > how do i get the time

Re: For those ready to take the challenge

2015-01-10 Thread Daniel Kozak via Digitalmars-d-learn
Vladimir Panteleev via Digitalmars-d-learn píše v So 10. 01. 2015 v 07:42 +: > On Saturday, 10 January 2015 at 02:10:04 UTC, Jesse Phillips > wrote: > > On Friday, 9 January 2015 at 13:50:29 UTC, eles wrote: > >> https://codegolf.stackexchange.com/questions/44278/debunking-stroustrups-debunkin

Re: Parameterized enum does not work

2015-01-09 Thread Daniel Kozak via Digitalmars-d-learn
On Friday, 9 January 2015 at 07:52:50 UTC, Daniel Kozak wrote: On Friday, 9 January 2015 at 07:50:53 UTC, Daniel Kozak wrote: On Friday, 9 January 2015 at 06:17:53 UTC, Andre wrote: Hi, Should following coding work? string lpad(ubyte length, long n) { import std.string: rightJustify

Re: Parameterized enum does not work

2015-01-08 Thread Daniel Kozak via Digitalmars-d-learn
On Friday, 9 January 2015 at 07:50:53 UTC, Daniel Kozak wrote: On Friday, 9 January 2015 at 06:17:53 UTC, Andre wrote: Hi, Should following coding work? string lpad(ubyte length, long n) { import std.string: rightJustify; import std.conv: to; return rightJustify(to

Re: Parameterized enum does not work

2015-01-08 Thread Daniel Kozak via Digitalmars-d-learn
On Friday, 9 January 2015 at 06:17:53 UTC, Andre wrote: Hi, Should following coding work? string lpad(ubyte length, long n) { import std.string: rightJustify; import std.conv: to; return rightJustify(to!string(n), length, '0'); } enum lpad14(long n) = lpad(14, n

What exactly shared means?

2015-01-02 Thread Daniel Kozak via Digitalmars-d-learn
I always think that shared should be use to make variable global across threads (similar to __gshared) with some synchronize protection. But this code doesn't work (app is stuck on _aaGetX or _aaRehash ): shared double[size_t] logsA; void main() { auto logs = new double[1_000_000];

Re: Scoped external function declaration

2015-01-01 Thread Daniel Kozak via Digitalmars-d-learn
On Thursday, 1 January 2015 at 17:51:46 UTC, novice2 wrote: I want to use external or C function. It used only one time from one D function. I want do declare C function inside D function. I don't want to declare C function in global scope. Is my wish correct? Reduced code: extern (C) int get

Re: Call of rmdir in destructor causes InvalidMemoryOperationError

2015-01-01 Thread Daniel Kozak via Digitalmars-d-learn
Timo Gransch via Digitalmars-d-learn píše v Čt 01. 01. 2015 v 16:14 +0100: > Hi, > > I have a class which unzips an archive into a temporary directory below the > system temp folder. I want to delete this temporary directory in the class's > destructor, but when I call rmdir there, I get an > >

Re: Passing string literals to C

2014-12-31 Thread Daniel Kozák via Digitalmars-d-learn
V Wed, 31 Dec 2014 11:19:35 + Laeeth Isharc via Digitalmars-d-learn napsáno: > Argh - no way to edit. > > What's best practice here? > > D strings are not null-terminated. > === > cpling.c > > char* cpling(char *s) > { >s[0]='!'; >return s; > } > === > dcaller.d > > extern(C) char

Re: Define methods using templates

2014-12-30 Thread Daniel Kozák via Digitalmars-d-learn
V Tue, 30 Dec 2014 13:17:08 + Claude via Digitalmars-d-learn napsáno: > Hello, I'm trying to use templates to define several methods > (property setters) within a class to avoid some code duplication. > Here is an attempt: > > class Camera > { > private: > Vector4 m_pos; > float m

Re: Is D's GC.calloc and C's memset played the same role?

2014-12-23 Thread Daniel Kozak via Digitalmars-d-learn
FrankLike via Digitalmars-d-learn píše v Út 23. 12. 2014 v 15:37 +: > Today,I meet a question:get all processes names. > > --C++ CODE- > #include "stdafx.h" > #include > #include //C standard I/O > #include > > int _tmain(int argc, _TCHAR* argv[]) > { > HAND

Re: math.log() benchmark of first 1 billion int using std.parallelism

2014-12-23 Thread Daniel Kozak via Digitalmars-d-learn
On Tuesday, 23 December 2014 at 12:31:47 UTC, Iov Gherman wrote: Btw. I just noticed small issue with D vs. java, you start messure in D before allocation, but in case of Java after allocation Here is the java result for parallel processing after moving the start time as the first line in m

Re: math.log() benchmark of first 1 billion int using std.parallelism

2014-12-23 Thread Daniel Kozak via Digitalmars-d-learn
On Tuesday, 23 December 2014 at 10:20:04 UTC, Iov Gherman wrote: That's very different to my results. I see no important difference between ldc and dmd when using std.math, but when using core.stdc.math ldc halves its time where dmd only manages to get to ~80% I checked again today and the r

Re: math.log() benchmark of first 1 billion int using std.parallelism

2014-12-23 Thread Daniel Kozak via Digitalmars-d-learn
On Tuesday, 23 December 2014 at 10:39:13 UTC, Iov Gherman wrote: These multi-threaded benchmarks can be very sensitive to their environment, you should try running it with nice -20 and do multiple passes to get a vague idea of the variability in the result. Also, it's important to minimise th

Re: math.log() benchmark of first 1 billion int using std.parallelism

2014-12-22 Thread Daniel Kozak via Digitalmars-d-learn
That's very different to my results. I see no important difference between ldc and dmd when using std.math, but when using core.stdc.math ldc halves its time where dmd only manages to get to ~80% What CPU do you have? On my Intel Core i3 I have similar experience as Iov Gherman, but on my A

Re: math.log() benchmark of first 1 billion int using std.parallelism

2014-12-22 Thread Daniel Kozak via Digitalmars-d-learn
On Monday, 22 December 2014 at 10:35:52 UTC, Daniel Kozak via Digitalmars-d-learn wrote: I run Arch Linux on my PC. I compiled D programs using dmd-2.066 and used no compile arguments (dmd prog.d) You should try use some arguments -O -release -inline -noboundscheck and maybe try use gdc or

Re: math.log() benchmark of first 1 billion int using std.parallelism

2014-12-22 Thread Daniel Kozak via Digitalmars-d-learn
> I run Arch Linux on my PC. I compiled D programs using dmd-2.066 > and used no compile arguments (dmd prog.d) You should try use some arguments -O -release -inline -noboundscheck and maybe try use gdc or ldc should help with performance can you post your code in all languages somewhere? I lik

Re: Non-blocking UDP calls using std.socket

2014-12-17 Thread Daniel Kozák via Digitalmars-d-learn
V Wed, 17 Dec 2014 08:20:42 + Andre Artus via Digitalmars-d-learn napsáno: > I've written a small program that uses UdpSocket (std.socket) to > query a DNS server for selected records. > > It works as expected, but I would like to try a non-blocking > approach. > > The last time I wrote s

Re: struct vs built-in type

2014-12-17 Thread Daniel Kozák via Digitalmars-d-learn
V Wed, 17 Dec 2014 07:57:24 + Jack Applegame via Digitalmars-d-learn napsáno: > Code: > > import std.stdio; > > struct Bar { > int payload; > alias payload this; > } > struct Foo { > private { > Bar m_bar; > int m_baz; > } > @propert

Re: Template mixin enum stringof

2014-12-10 Thread Daniel Kozák via Digitalmars-d-learn
V Wed, 10 Dec 2014 12:35:44 + Lemonfiend via Digitalmars-d-learn napsáno: > On Wednesday, 10 December 2014 at 12:08:34 UTC, ketmar via > Digitalmars-d-learn wrote: > > On Wed, 10 Dec 2014 11:52:11 + > > Lemonfiend via Digitalmars-d-learn > > > > wrote: > > > >> Consider the following:

<    1   2   3   4   5   6   7   8   9   10   >