Re: It is a bug?

2014-07-30 Thread Daniel Kozak via Digitalmars-d-learn
On Wednesday, 30 July 2014 at 16:14:56 UTC, Jesse Phillips wrote: On Wednesday, 30 July 2014 at 07:08:17 UTC, Kozzi11 wrote: #main.d: import m.f; class A { //class main.A member m is not accessible //mixin(t!(typeof(this), m)); void m() {}; //here is ok //mixin(t!(typeof(this),

Re: pointer array?

2014-07-30 Thread Daniel Kozak via Digitalmars-d-learn
V Wed, 30 Jul 2014 14:33:51 + seany via Digitalmars-d-learn digitalmars-d-learn@puremagic.com napsáno: In Ali's excllent book, somehow one thing has escaped my attention, and that it the mentioning of pointer arrays. Can pointers of any type of pointed variable be inserted in an int

Re: Member access of __gshared global object

2014-07-31 Thread Daniel Kozak via Digitalmars-d-learn
V Thu, 31 Jul 2014 02:03:35 + Puming via Digitalmars-d-learn digitalmars-d-learn@puremagic.com napsáno: Hi, I'm writing this global Config class, with an AA member: ```d module my.config; class Config { Command[string] commands; } __gshared Config CONFIG; ``` and

Re: Split class declaration and definition

2014-07-31 Thread Daniel Kozak via Digitalmars-d-learn
V Thu, 31 Jul 2014 13:26:38 + Kagamin via Digitalmars-d-learn digitalmars-d-learn@puremagic.com napsáno: On Thursday, 31 July 2014 at 12:02:22 UTC, Kozzi11 wrote: module m; @someUda class C { void someFun(); } @someUda class D { void anotherFun(); }

Re: A significant performance difference

2014-09-01 Thread Daniel Kozak via Digitalmars-d-learn
V Sun, 31 Aug 2014 10:55:31 + bearophile via Digitalmars-d-learn digitalmars-d-learn@puremagic.com napsáno: This is C++ code that solves one Euler problem: -- #include stdio.h #include map const unsigned int H = 9, W = 12; const int g[6][3] = {{7, 0, H - 3},

Re: A significant performance difference

2014-09-01 Thread Daniel Kozak via Digitalmars-d-learn
V Mon, 1 Sep 2014 12:38:52 +0300 ketmar via Digitalmars-d-learn digitalmars-d-learn@puremagic.com napsáno: On Mon, 01 Sep 2014 09:22:50 + bearophile via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: In theory the best solution is to improve the performance of the

Re: alias this cast

2014-09-11 Thread Daniel Kozak via Digitalmars-d-learn
V Thu, 11 Sep 2014 11:40:05 + andre via Digitalmars-d-learn digitalmars-d-learn@puremagic.com napsáno: Hi, I am 80% sure, the failing assertion is correct but please have a look. No it is not assert(cast(A)cast(C)b); // this is OK b is B so it does not know about having alias to A;

Re: std.algorithm.reduce on an array of structs

2014-09-11 Thread Daniel Kozak via Digitalmars-d-learn
On Thursday, 11 September 2014 at 13:06:05 UTC, Colin wrote: I have this test code: struct Thing { uint x; } void main(){ uint[] ar1 = [1, 2, 3, 4, 5]; auto min1 = ar1.reduce!((a,b) = a b); writefln(%s, min1); // prints 1 as expected Thing[] ar2 = [Thing(1), Thing(2),

Re: std.algorithm.reduce on an array of structs

2014-09-11 Thread Daniel Kozak via Digitalmars-d-learn
On Thursday, 11 September 2014 at 14:18:31 UTC, Colin wrote: Ah ok. I get it. Thanks daniel! a quiet better version: import std.stdio; import std.algorithm; struct Thing { uint x; alias x this; } void main(){ uint[] ar1 = [1, 2, 3, 4, 5]; auto min1 =

Re: std.algorithm.reduce on an array of structs

2014-09-11 Thread Daniel Kozak via Digitalmars-d-learn
On Thursday, 11 September 2014 at 14:39:53 UTC, Daniel Kozak wrote: On Thursday, 11 September 2014 at 14:18:31 UTC, Colin wrote: Ah ok. I get it. Thanks daniel! a quiet better version: import std.stdio; import std.algorithm; struct Thing { uint x; alias x this; } void

Re: std.algorithm.reduce on an array of structs

2014-09-11 Thread Daniel Kozak via Digitalmars-d-learn
V Thu, 11 Sep 2014 14:49:02 + bearophile via Digitalmars-d-learn digitalmars-d-learn@puremagic.com napsáno: Daniel Kozak: You can just use min: import std.stdio, std.algorithm; struct Thing { uint x; alias x this; } alias minimum = reduce!min; void main() {

Re: std.algorithm.reduce on an array of structs

2014-09-11 Thread Daniel Kozak via Digitalmars-d-learn
On Thursday, 11 September 2014 at 14:56:00 UTC, Daniel Kozak via Digitalmars-d-learn wrote: V Thu, 11 Sep 2014 14:49:02 + bearophile via Digitalmars-d-learn digitalmars-d-learn@puremagic.com napsáno: Daniel Kozak: You can just use min: import std.stdio, std.algorithm; struct Thing

Re: std.algorithm.reduce on an array of structs

2014-09-11 Thread Daniel Kozak via Digitalmars-d-learn
On Thursday, 11 September 2014 at 15:07:03 UTC, Daniel Kozak wrote: or use alias minimum = reduce!a b; ;) ok this one does not work

Re: Is there a function that reads the entire contents of a std.stdio.File?

2014-09-16 Thread Daniel Kozak via Digitalmars-d-learn
V Tue, 16 Sep 2014 14:37:05 + Jay via Digitalmars-d-learn digitalmars-d-learn@puremagic.com napsáno: all the functions/methods i've come across so far deal with either streams or just file names (like std.file.read) and there doesn't seem to be a way to wrap a std.stdio.File in a stream

parallel foreach hangs

2014-09-22 Thread Daniel Kozak via Digitalmars-d-learn
this code never end import std.stdio; import std.file; import std.parallelism : parallel; import std.algorithm : filter; void main(string[] args) { foreach(d; parallel(args[1 .. $], 1)) { auto phpFiles = filter!`endsWith(a.name,.php)`(dirEntries(d,SpanMode.depth));

Re: Does D has C#'s string.Empty?

2014-09-25 Thread Daniel Kozak via Digitalmars-d-learn
V Thu, 25 Sep 2014 05:29:36 + AsmMan via Digitalmars-d-learn digitalmars-d-learn@puremagic.com napsáno: Does D has C#'s string.Empty? string.init

Re: curl and proxy

2014-10-03 Thread Daniel Kozak via Digitalmars-d-learn
On Friday, 3 October 2014 at 11:13:11 UTC, Marc Schütz wrote: On Friday, 3 October 2014 at 10:53:27 UTC, Marc Schütz wrote: On Friday, 3 October 2014 at 04:57:28 UTC, AntonSotov wrote: auto http = HTTP(dlang.org); http.onReceive = (ubyte[] data) { writeln(cast(string) (data)); return

Re: Best way to add slash to tail of the path

2014-11-27 Thread Daniel Kozak via Digitalmars-d-learn
Dne Thu, 27 Nov 2014 21:20:24 +0100 Suliman via Digitalmars-d-learn digitalmars-d-learn@puremagic.com napsal(a): take a second look then. ;-) you'll find `buildPath()` here too. Not better: string foo = D:/code/txtDownloader; writeln(foo); foo = foo.buildPath;

Re: Best way to add slash to tail of the path

2014-11-27 Thread Daniel Kozak via Digitalmars-d-learn
try first few sentences and looked at the example ;) Dne Thu, 27 Nov 2014 21:42:31 +0100 Suliman via Digitalmars-d-learn digitalmars-d-learn@puremagic.com napsal(a): Could you quote for me part of docs where it's written? I really can't understand about what you are taking. -- Vytvořeno

Re: function app.download (string[] links) is not callableusing argument types (string, string)

2014-11-27 Thread Daniel Kozak via Digitalmars-d-learn
Dne Thu, 27 Nov 2014 18:39:09 +0100 Suliman via Digitalmars-d-learn digitalmars-d-learn@puremagic.com napsal(a): Is there any way to detect where collision was occurred? Yes, read error description it has been app.download I guess -- Vytvořeno poštovní aplikací Opery:

Re: Error: cannot return non-void from void function

2014-11-27 Thread Daniel Kozak via Digitalmars-d-learn
On Thursday, 27 November 2014 at 17:22:36 UTC, Suliman wrote: ah, that's it! as spec says, D determines function return value from the first 'return' statement it seen. in your case this is `return;`, so function return type is determined to be `void`. if you doing `auto` functions, try to

Re: Error: cannot return non-void from void function

2014-11-27 Thread Daniel Kozak via Digitalmars-d-learn
Dne Thu, 27 Nov 2014 22:21:52 +0100 ketmar via Digitalmars-d-learn digitalmars-d-learn@puremagic.com napsal(a): On Thu, 27 Nov 2014 21:14:57 + Daniel Kozak via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: import core.runtime; import

Re: How to initialise array of ubytes?

2014-11-29 Thread Daniel Kozak via Digitalmars-d-learn
Dne Sat, 29 Nov 2014 21:10:41 +0100 Paul via Digitalmars-d-learn digitalmars-d-learn@puremagic.com napsal(a): I'm trying to do this: ubyte[MAPSIZE][MAPSIZE] map = 1; but it doesn't work and I can't seem to cast the value to a ubyte (which looks rather ugly and out of place in D anyway).

Re: How to initialise array of ubytes?

2014-11-29 Thread Daniel Kozak via Digitalmars-d-learn
On Saturday, 29 November 2014 at 20:45:34 UTC, bearophile wrote: Daniel Kozak: http://stackoverflow.com/questions/24600796/d-set-default-value-for-a-struct-member-which-is-a-multidimensional-static-arr/24754361#24754361 Do you also know why the simplest syntax doesn't work? Can't it be

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 like

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

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

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

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

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

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 windows.h #include stdio.h//C standard I/O #include tlhelp32.h int _tmain(int argc, _TCHAR* argv[])

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: 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

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: 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

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.Runtime. So

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: 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:

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,

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

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: 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 digitalmars-d-learn@puremagic.com napsáno: On Tuesday, 13 January 2015 at 13:53:11 UTC, tcak wrote: I have written the following code:

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 digitalmars-d-learn@puremagic.com 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:

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 digitalmars-d-learn@puremagic.com 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 digitalmars-d-learn

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: 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: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 digitalmars-d-learn@puremagic.com

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 digitalmars-d-learn@puremagic.com wrote: On Thursday, 7 May 2015 at 10:43:28 UTC, Daniel Kozak

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 digitalmars-d-learn@puremagic.com 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

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 digitalmars-d-learn@puremagic.com wrote: struct S { int i; auto foo2(T)(int j) { i=j; } static S foo(T)(int j) { S 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 digitalmars-d-learn@puremagic.com 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'; //

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 digitalmars-d-learn@puremagic.com 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'; //

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 digitalmars-d-learn@puremagic.com wrote: Hi, It seems to me, or D do not create mutable array of strings? How to create a mutable equivalent of a string

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 digitalmars-d-learn@puremagic.com wrote: Hi, It seems to me, or D do not create mutable array of

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

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: 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 = to!(char[][])([foo, bar]);

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 digitalmars-d-learn@puremagic.com 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

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 digitalmars-d-learn@puremagic.com 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:

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 digitalmars-d-learn@puremagic.com 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

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 digitalmars-d-learn@puremagic.com 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

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 digitalmars-d-learn@puremagic.com wrote: I remembered code Ali Çereli. It really helped:

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 10:36:33 + Namespace via Digitalmars-d-learn digitalmars-d-learn@puremagic.com 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 digitalmars-d-learn@puremagic.com wrote: On

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 digitalmars-d-learn@puremagic.com wrote: Executing this code: import std.container.array; import std.stdio; int main() { writeln(Array!int([1, 2])); return 0; } outputs the following:

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 digitalmars-d-learn@puremagic.com 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() {

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 digitalmars-d-learn@puremagic.com wrote: Hi. I want to call a C library function that returns a data buffer as a void*. How do I convert the resulting

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 digitalmars-d-learn@puremagic.com 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;

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 digitalmars-d-learn@puremagic.com wrote: Hi! Excuse me if this is obvious, but I can't recall coming across anything similar and a quick search returns nothing

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 digitalmars-d-learn@puremagic.com wrote: Hi! Excuse me if this is obvious, but I can't recall coming

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.067.0

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 Compiler v2.067.0

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 params): Name:

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: 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 digitalmars-d-learn@puremagic.com wrote: I don't understand why this behaves as it does. Given the following two templates: ``` void printVal(T)(T t) {

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

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: Utf8 to Utf32 cast cost

2015-06-08 Thread Daniel Kozak via Digitalmars-d-learn
On Mon, 08 Jun 2015 18:16:57 + Anonymouse via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: On Monday, 8 June 2015 at 11:44:47 UTC, Daniel Kozák wrote: No difference even with GC.disable() results are same. Profile! Callgrind is your friend~ Yep, but I dont care, I am

Re: Abstract sockets (linux)

2015-06-25 Thread Daniel Kozak via Digitalmars-d-learn
On Thu, 25 Jun 2015 15:56:04 + freeman via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: I am having trouble using abstract sockets on Linux. Here is sample python code that works, which works: ptm_sockname = \0/var/run/ptmd.socket sock =

Re: Qualified destructors / immutable objects

2015-06-13 Thread Daniel Kozak via Digitalmars-d-learn
On Friday, 12 June 2015 at 15:36:22 UTC, anonymous wrote: no need for ~this() to modify immutable data: class C { int a; this(int a) { this.a = a; } } struct S { C elem = new C(42); } void main() { import std.stdio; immutable(S) s1;

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

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: 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 digitalmars-d-learn@puremagic.com 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

Re: Static arrays inside struct and class - bug?

2015-08-01 Thread Daniel Kozak via Digitalmars-d-learn
V Sat, 01 Aug 2015 19:21:36 + NX via Digitalmars-d-learn digitalmars-d-learn@puremagic.com napsáno: On Saturday, 1 August 2015 at 18:50:09 UTC, Daniel Kozak wrote: No you don't. You still use static allocation for array Can clarify why does that happen and I still suspect it's a

Re: Static arrays inside struct and class - bug?

2015-08-01 Thread Daniel Kozak via Digitalmars-d-learn
On Saturday, 1 August 2015 at 18:07:51 UTC, NX wrote: On Saturday, 1 August 2015 at 17:29:54 UTC, Adam D. Ruppe wrote: Sorry, I can't see _the_ point in that. I understand that could be a problem if it was a global array but this scenery is completely wrong in my view. I'm already going to

Re: Static arrays inside struct and class - bug?

2015-08-01 Thread Daniel Kozak via Digitalmars-d-learn
V Sat, 01 Aug 2015 19:16:16 + NX via Digitalmars-d-learn digitalmars-d-learn@puremagic.com napsáno: On Saturday, 1 August 2015 at 18:47:00 UTC, Daniel Kozak wrote: Still same problem, You can`t allocate more then 16M on stack. Use dynamic allocation I don't think new MyStruct

Re: Static arrays inside struct and class - bug?

2015-08-01 Thread Daniel Kozak via Digitalmars-d-learn
V Sat, 01 Aug 2015 18:07:50 + NX via Digitalmars-d-learn digitalmars-d-learn@puremagic.com napsáno: On Saturday, 1 August 2015 at 17:29:54 UTC, Adam D. Ruppe wrote: On Saturday, 1 August 2015 at 17:22:40 UTC, NX wrote: I wonder if the followings are compiler bugs: No, it is by

Re: [dmd2.068] Bug or future?

2015-08-07 Thread Daniel Kozak via Digitalmars-d-learn
On Friday, 7 August 2015 at 06:26:21 UTC, VlasovRoman wrote: I have some code: import std.stdio; auto dot(T, R)(T x, R y) { return x * y; } struct Vector(T) { alias selftype = Vector!T; int len = 5; pure: const @property{ static if( is( typeof( dot( selftype.init,

Re: zlib performance

2015-08-07 Thread Daniel Kozak via Digitalmars-d-learn
On Friday, 7 August 2015 at 09:12:32 UTC, yawniek wrote: On Friday, 7 August 2015 at 08:50:11 UTC, Daniel Kozák wrote: ldc[2] -O -release -boundscheck=off -singleobj app.d ldc 0.15.2 beta2 2.86s user 0.55s system 77% cpu 4.392 total v2.068-devel-8f81ffc 2.86s user 0.67s system 78% cpu

Re: What D really needs :D

2015-07-25 Thread Daniel Kozak via Digitalmars-d-learn
On Saturday, 25 July 2015 at 18:30:16 UTC, Daniel Kozak wrote: https://github.com/avinassh/rockstar?utm_content=buffer64b3cutm_medium=socialutm_source=twitter.comutm_campaign=buffer Wrong forum, someone put learn on top. http://forum.dlang.org/post/ooybhdoonxoxkzdsz...@forum.dlang.org

What D really needs :D

2015-07-25 Thread Daniel Kozak via Digitalmars-d-learn
https://github.com/avinassh/rockstar?utm_content=buffer64b3cutm_medium=socialutm_source=twitter.comutm_campaign=buffer

Re: static linking

2015-07-25 Thread Daniel Kozak via Digitalmars-d-learn
On Sat, 25 Jul 2015 18:02:46 + Laeeth Isharc via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: Hi. Is static linking with dmd still broken on linux? If so, can I link statically with gdc or ldc, and if so how? https://issues.dlang.org/show_bug.cgi?id=12268 I am

Re: OSX Foundation framework D binding

2015-11-11 Thread Daniel Kozak via Digitalmars-d-learn
V Wed, 11 Nov 2015 06:17:00 + Vadim Lopatin via Digitalmars-d-learn napsáno: > Hello, > > I'm working on native Cocoa backend for DlangUI GUI library under > OSX. > Is there any ready to use bindings for easy accessing Cocoa API? > Probably, there is some

Re: my first D program (and benchmark against perl)

2015-11-12 Thread Daniel Kozak via Digitalmars-d-learn
On Wednesday, 11 November 2015 at 13:32:00 UTC, perlancar wrote: Here's my first non-hello-world D program, which is a direct translation from the Perl version. I was trying to get a feel about D's performance: ... While I am quite impressed with how easy I was able to write D, I am not so

Re: my first D program (and benchmark against perl)

2015-11-12 Thread Daniel Kozak via Digitalmars-d-learn
V Thu, 12 Nov 2015 09:12:32 + Daniel Kozak via Digitalmars-d-learn <digitalmars-d-learn@puremagic.com> napsáno: > On Wednesday, 11 November 2015 at 13:32:00 UTC, perlancar wrote: > > Here's my first non-hello-world D program, which is a direct > > translation fro

Re: my first D program (and benchmark against perl)

2015-11-12 Thread Daniel Kozak via Digitalmars-d-learn
V Thu, 12 Nov 2015 11:03:38 + Tobias Pankrath via Digitalmars-d-learn napsáno: > > or with ~ operator: > > > > import std.stdio; > > > > [...] > > Did anyone check that the last loop isn't optimized out? Yes, it is not optimized out > Could also be

Re: my first D program (and benchmark against perl)

2015-11-12 Thread Daniel Kozak via Digitalmars-d-learn
V Thu, 12 Nov 2015 12:13:10 + perlancar via Digitalmars-d-learn napsáno: > On Wednesday, 11 November 2015 at 14:20:51 UTC, Rikki Cattermole > wrote: > > I turned it into mostly using large allocations, instead of > > small ones. > > Although I'd recommend

Re: my first D program (and benchmark against perl)

2015-11-12 Thread Daniel Kozak via Digitalmars-d-learn
On Thursday, 12 November 2015 at 12:25:08 UTC, Daniel Kozak wrote: V Thu, 12 Nov 2015 12:13:10 + perlancar via Digitalmars-d-learn napsáno: On Wednesday, 11 November 2015 at 14:20:51 UTC, Rikki Cattermole wrote: > I turned it into mostly using large

Re: my first D program (and benchmark against perl)

2015-11-12 Thread Daniel Kozak via Digitalmars-d-learn
On Thursday, 12 November 2015 at 12:49:55 UTC, Daniel Kozak wrote: On Thursday, 12 November 2015 at 12:25:08 UTC, Daniel Kozak wrote: ... auto res = appender(uninitializedArray!(char[])(total)); res.clear(); ... this is faster for DMD and ldc: auto res = appender!(string)();

  1   2   3   4   5   >