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, 07 May 2015 10:

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 at 1

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); retu

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 proce

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 a

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

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 { } struct FooWrap

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

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

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: > > test.d > ==

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!stri

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

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 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). Is there a way to do this other t

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 napsal(a): On Thu, 27 Nov 2014 21:14:57 + Daniel Kozak via Digitalmars-d-learn wrote: import core.runtime; import std.c.process; writeln("Can't find input file

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 a

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 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: http://www.opera.com/mail/

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 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 poštovní aplikací Opery: http://w

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 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; foo ~= "config.txt";

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 data

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

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

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)); wr

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 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 (or > is there?). i need a fun

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: 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 napsáno: Daniel Kozak: You can just use min: import std.stdio, std.algorithm; struct Thing { uint x; alias x this

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 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() { > immutable ar1 = [1

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 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: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 = ar1.red

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: 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 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; > Second assertion fails. > >

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 napsáno: > On Mon, 01 Sep 2014 09:22:50 + > bearophile via Digitalmars-d-learn > wrote: > > > In theory the best solution is to improve the performance of the > > "byKey.front" and "byValue.front" idioms. > i found that slowdo

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 napsáno: > This is C++ code that solves one Euler problem: > > -- > #include > #include > > const unsigned int H = 9, W = 12; > > const int g[6][3] = {{7, 0, H - 3}, > {1 + (1 << H) + (1 <<

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 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(); > > } > > > > mixin(generateFunDe

Re: Member access of __gshared global object

2014-07-30 Thread Daniel Kozak via Digitalmars-d-learn
V Thu, 31 Jul 2014 02:03:35 + Puming via Digitalmars-d-learn 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 initialize it in anot

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 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 array? Using to!(int) perhaps?

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),

<    1   2   3   4   5