Re: New vs length on dymamic array

2020-11-09 Thread Daniel Kozák via Digitalmars-d-learn
On Monday, 9 November 2020 at 08:06:54 UTC, Andrey wrote: Hello, Are here any differences in creation of dynamic array with known size? auto array = new wchar[](111); and wchar[] array; array.length = 111; In theory auto array = new wchar[111]; // or new wchar[](111); should do less

Re: 1 - 17 ms, 553 ╬╝s, and 1 hnsec

2019-05-27 Thread Daniel Kozák via Digitalmars-d-learn
On Friday, 17 May 2019 at 18:02:04 UTC, kdevel wrote: On Thursday, 16 May 2019 at 20:31:23 UTC, Vladimir Panteleev wrote: On Thursday, 16 May 2019 at 20:17:37 UTC, Steven Schveighoffer [...] hnsecs is more confusing than nanoseconds. People know what a nanosecond is, a hecto-nano-second is

Re: Why GNU coreutils/dd is creating a dummy file more efficiently than D's For loop?

2019-05-23 Thread Daniel Kozák via Digitalmars-d-learn
On Thursday, 23 May 2019 at 18:37:17 UTC, H. S. Teoh wrote: On Thu, May 23, 2019 at 06:20:23PM +, kdevel via Digitalmars-d-learn wrote: On Thursday, 23 May 2019 at 09:44:15 UTC, Cym13 wrote: [...] > To go fast, read/write bigger chunks. Or use rawWrite instead of write (reduces the

Re: D money data type compatible with postgresql money

2018-11-17 Thread Daniel Kozák via Digitalmars-d-learn
On Saturday, 17 November 2018 at 12:35:45 UTC, Daniel Kozák wrote: On Saturday, 17 November 2018 at 11:48:56 UTC, Václav Kozák wrote: Hello, I have a column of type money in my database. I need to pull the data from the db in my vibe.d backend, but it can't handle such data type. How can I do

Re: D money data type compatible with postgresql money

2018-11-17 Thread Daniel Kozák via Digitalmars-d-learn
On Saturday, 17 November 2018 at 11:48:56 UTC, Václav Kozák wrote: Hello, I have a column of type money in my database. I need to pull the data from the db in my vibe.d backend, but it can't handle such data type. How can I do it? Should I use some library (which?)? Thanks. You could use

Re: Why does this compile (method in class without return type)

2017-05-03 Thread Daniel Kozák via Digitalmars-d-learn
V Wed, 03 May 2017 09:21:47 + nkm1 via Digitalmars-d-learn napsáno: > On Wednesday, 3 May 2017 at 07:34:03 UTC, Daniel Kozák wrote: > > > > print in A is template: > > > > What :) > How does it interact with 'final'? hmm obviously it is problem only

Re: Why does this compile (method in class without return type)

2017-05-03 Thread Daniel Kozák via Digitalmars-d-learn
V Wed, 03 May 2017 09:21:47 + nkm1 via Digitalmars-d-learn napsáno: > On Wednesday, 3 May 2017 at 07:34:03 UTC, Daniel Kozák wrote: > > > > print in A is template: > > > > What :) > How does it interact with 'final'? final is not important here

Re: Why does this compile (method in class without return type)

2017-05-03 Thread Daniel Kozák via Digitalmars-d-learn
V Wed, 03 May 2017 06:54:15 + nkm1 via Digitalmars-d-learn napsáno: > Consider: > > import std.stdio; > > class A > { > final print() { writeln(this); } // no return type > } > > class B : A > { > final void print() { writeln(this); } > } > >

Re: Why File is exists in std.stdio and in std.file?

2017-04-25 Thread Daniel Kozák via Digitalmars-d-learn
V Tue, 25 Apr 2017 07:05:51 + Suliman via Digitalmars-d-learn napsáno: > Just interesting. Is there any rational reasons for this decision? No it isn't. File is only in std.stdio;

Re: foreach for string[string]AA

2017-02-28 Thread Daniel Kozák via Digitalmars-d-learn
V Tue, 28 Feb 2017 15:15:00 + Anton Pastukhov via Digitalmars-d-learn napsáno: > I can't see the logic in AA foreach order. Consider this code: > ... > Output: > three > two > one > four > > I was sure output should be > one > two > three > four

Re: Copying and moving directories

2017-02-16 Thread Daniel Kozák via Digitalmars-d-learn
V Thu, 16 Feb 2017 16:38:51 + Chris via Digitalmars-d-learn napsáno: > In `std.file`, I haven't found a function that allows me to move > or at least copy directories, as in `mv dir /toDir`. Do I have to > go the awkward way over `rename` or something?

Re: Static array size?

2017-02-09 Thread Daniel Kozák via Digitalmars-d-learn
V Thu, 09 Feb 2017 11:22:28 + Suliman via Digitalmars-d-learn napsáno: > Docs says that: > "The total size of a static array cannot exceed 16Mb." > But when I am creation array of: > int [1000_000] x; // 1000_000 is equal ~ 0,95MB > app crush on start. > >

Re: Does vibe.d support setting cookies?

2017-02-01 Thread Daniel Kozák via Digitalmars-d-learn
V Wed, 01 Feb 2017 14:09:41 + aberba via Digitalmars-d-learn napsáno: > I can't find it. Like set_cookie() in php. maybe this http://vibed.org/api/vibe.http.server/HTTPServerResponse.setCookie

Re: Does vibe.d support setting cookies?

2017-02-01 Thread Daniel Kozák via Digitalmars-d-learn
V Wed, 01 Feb 2017 14:09:41 + aberba via Digitalmars-d-learn napsáno: > I can't find it. Like set_cookie() in php. I am not sure but I use this in one of my projects import vibe.http.client; auto clientOCX = new RestInterfaceClient!I(host ~

Re: Parsing a UTF-16LE file line by line, BUG?

2017-01-15 Thread Daniel Kozák via Digitalmars-d-learn
V Sun, 15 Jan 2017 14:48:12 + Nestor via Digitalmars-d-learn napsáno: > On Friday, 6 January 2017 at 11:42:17 UTC, Mike Wey wrote: > > On 01/06/2017 11:33 AM, pineapple wrote: > >> On Friday, 6 January 2017 at 06:24:12 UTC, rumbu wrote: > >

Re: Mysql-native - full database backup

2017-01-05 Thread Daniel Kozák via Digitalmars-d-learn
Geert via Digitalmars-d-learn napsal Čt, led 5, 2017 v 3∶13 : On Thursday, 5 January 2017 at 01:16:09 UTC, crimaniak wrote: On Monday, 2 January 2017 at 15:29:08 UTC, Geert wrote: Hi! How can i create a full database backup using mysql-native for D? Too

Re: Parsing a UTF-16LE file line by line, BUG?

2017-01-04 Thread Daniel Kozák via Digitalmars-d-learn
Nestor via Digitalmars-d-learn napsal St, led 4, 2017 v 8∶20 : On Wednesday, 4 January 2017 at 18:48:59 UTC, Daniel Kozák wrote: Ok, I've done some testing and you are right byLine is broken, so please fill a bug A bug? I was under the impression that this

Re: Parsing a UTF-16LE file line by line?

2017-01-04 Thread Daniel Kozák via Digitalmars-d-learn
Daniel Kozák napsal St, led 4, 2017 v 6∶33 : Nestor via Digitalmars-d-learn napsal St, led 4, 2017 v 12∶03 : Hi, I was just trying to parse a UTF-16LE file using byLine, but apparently this function doesn't work with anything other

Re: Parsing a UTF-16LE file line by line?

2017-01-04 Thread Daniel Kozák via Digitalmars-d-learn
Nestor via Digitalmars-d-learn napsal St, led 4, 2017 v 12∶03 : Hi, I was just trying to parse a UTF-16LE file using byLine, but apparently this function doesn't work with anything other than UTF-8, because I get this error: "Invalid UTF-8 sequence (at

Re: String characters not extended

2017-01-03 Thread Daniel Kozák via Digitalmars-d-learn
Anonymouse via Digitalmars-d-learn napsal Út, led 3, 2017 v 12∶34 : On Monday, 2 January 2017 at 21:07:37 UTC, Ignacious wrote: [...] Assuming Windows: version(Windows) shared static this() { import core.sys.windows.windows; SetConsoleCP(65001);

Re: Most performant way of converting int to string

2015-12-22 Thread Daniel Kozák via Digitalmars-d-learn
V Tue, 22 Dec 2015 18:39:16 + Ivan Kazmenko via Digitalmars-d-learn napsáno: > On Tuesday, 22 December 2015 at 18:11:24 UTC, rumbu wrote: > > On Tuesday, 22 December 2015 at 17:15:27 UTC, Andrew Chapman > > wrote: > >> Sorry if this is a silly question

Re: Most performant way of converting int to string

2015-12-22 Thread Daniel Kozák via Digitalmars-d-learn
V Tue, 22 Dec 2015 18:11:24 + rumbu via Digitalmars-d-learn napsáno: > On Tuesday, 22 December 2015 at 17:15:27 UTC, Andrew Chapman > wrote: > > Sorry if this is a silly question but is the to! method from > > the conv library the most efficient way of

Re: Most performant way of converting int to string

2015-12-22 Thread Daniel Kozák via Digitalmars-d-learn
V Tue, 22 Dec 2015 17:15:27 + Andrew Chapman via Digitalmars-d-learn napsáno: > Sorry if this is a silly question but is the to! method from the > conv library the most efficient way of converting an integer > value to a string? > > e.g. > string s =

Re: Most performant way of converting int to string

2015-12-22 Thread Daniel Kozák via Digitalmars-d-learn
V Tue, 22 Dec 2015 20:52:07 + rumbu via Digitalmars-d-learn napsáno: > On Tuesday, 22 December 2015 at 19:45:46 UTC, Daniel Kozák wrote: > > V Tue, 22 Dec 2015 18:11:24 + > > rumbu via Digitalmars-d-learn > > > >

Re: Most performant way of converting int to string

2015-12-22 Thread Daniel Kozák via Digitalmars-d-learn
V Tue, 22 Dec 2015 21:10:54 + rumbu via Digitalmars-d-learn napsáno: > On Tuesday, 22 December 2015 at 20:52:07 UTC, rumbu wrote: > > On Tuesday, 22 December 2015 at 19:45:46 UTC, Daniel Kozák > > wrote: > >> V Tue, 22 Dec 2015 18:11:24 + > >> rumbu

Re: Most performant way of converting int to string

2015-12-22 Thread Daniel Kozák via Digitalmars-d-learn
V Tue, 22 Dec 2015 09:43:00 -0800 "H. S. Teoh via Digitalmars-d-learn" napsáno: > On Tue, Dec 22, 2015 at 05:23:11PM +, Andrew Chapman via > Digitalmars-d-learn wrote: [...] > > for({int i; i = 0;} i < num; i++) { > > //string s =

Re: Most performant way of converting int to string

2015-12-22 Thread Daniel Kozák via Digitalmars-d-learn
V Tue, 22 Dec 2015 12:55:10 -0800 "H. S. Teoh via Digitalmars-d-learn" <digitalmars-d-learn@puremagic.com> napsáno: > On Tue, Dec 22, 2015 at 08:54:35PM +0100, Daniel Kozák via > Digitalmars-d-learn wrote: > > V Tue, 22 Dec 2015 09:43:00 -0800 > > &

Re: Socket - handling large numbers of incoming connections

2015-12-21 Thread Daniel Kozák via Digitalmars-d-learn
V Mon, 21 Dec 2015 20:53:14 + Jakob Jenkov via Digitalmars-d-learn napsáno: > On Monday, 21 December 2015 at 20:20:44 UTC, Stefan wrote: > > How about https://github.com/dcarp/asynchronous ? Asyncio > > Socket handling is sometimes quite nice. It's

Re: Reason for 'static struct'

2015-12-09 Thread Daniel Kozák via Digitalmars-d-learn
V Wed, 09 Dec 2015 21:10:43 + Jon D via Digitalmars-d-learn napsáno: > There is a fair bit of range related code in the standard library > structured like: > > auto MyRange(Range)(Range r) > if (isInputRange!Range) > { >

Re: D bindings for Bonjour

2015-10-28 Thread Daniel Kozák via Digitalmars-d-learn
V Wed, 28 Oct 2015 16:36:32 + Vincent R via Digitalmars-d-learn napsáno: > On Wednesday, 28 October 2015 at 16:12:08 UTC, Vincent R wrote: > > On Wednesday, 28 October 2015 at 16:09:02 UTC, Cauterite wrote: > >> On Wednesday, 28 October 2015 at 16:04:52

Re: Weird behaviour with File.eof

2015-09-20 Thread Daniel Kozák via Digitalmars-d-learn
V Sun, 20 Sep 2015 20:17:36 + Dandyvica via Digitalmars-d-learn napsáno: > Hi all, > > I can't explain to myself this weird behavior: > > void main(string[] argv) > { > char[] line; > auto fh = File(argv[1]); > while (!fh.eof) { >

Re: foreach(line; f.byLine) produces core.exception.InvalidMemoryOperationError@(0) in 2.067 but not 2.066

2015-09-15 Thread Daniel Kozák via Digitalmars-d-learn
On Tue, 15 Sep 2015 13:56:36 + Andrwe Brown via Digitalmars-d-learn wrote: > Hi, > > I'm trying to read a file line by line, and I get a > core.exception.InvalidMemoryOperationError@(0), even after > reducing the program to: > > import std.stdio; > >

Re: What is the difference between D and C++ regarding Unique, RefCounted and Scoped?

2015-09-10 Thread Daniel Kozák via Digitalmars-d-learn
On Thu, 10 Sep 2015 11:38:35 + "Gary Willoughby" wrote: > On Wednesday, 9 September 2015 at 23:22:49 UTC, ponce wrote: > > - RefCounted > > > > Only for D structs. std::shared_ptr works for all. > > RefCounted works with classes as well. > >

Re: order of declaration/definition

2015-08-27 Thread Daniel Kozák via Digitalmars-d-learn
On Thu, 27 Aug 2015 13:01:02 + vitus via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: On Monday, 24 August 2015 at 01:01:13 UTC, John Colvin wrote: enum A = 1; enum B = C; //Error static if(A) enum C = 0; enum D = C; //OK Is order supposed to matter here?

Re: order of declaration/definition

2015-08-27 Thread Daniel Kozák via Digitalmars-d-learn
On Thu, 27 Aug 2015 13:26:11 + vitus via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: On Thursday, 27 August 2015 at 13:14:24 UTC, Daniel Kozák wrote: On Thu, 27 Aug 2015 13:01:02 + vitus via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote:

Re: What is this function call operator?

2015-08-27 Thread Daniel Kozák via Digitalmars-d-learn
On Thu, 27 Aug 2015 15:18:22 + Gary Willoughby d...@nomad.so wrote: If you visit this link: http://dlang.org/phobos/std_traits.html#isCallable There is this paragraph: Detect whether T is a callable object, which can be called with the function call operator (...). What is

Re: zlib performance

2015-08-07 Thread Daniel Kozák via Digitalmars-d-learn
On Fri, 07 Aug 2015 08:42:45 + yawniek dl...@srtnwz.com wrote: On Friday, 7 August 2015 at 08:24:11 UTC, Daniel Kozák wrote: can you try it with ldc? 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

Re: zlib performance

2015-08-07 Thread Daniel Kozák via Digitalmars-d-learn
On Fri, 07 Aug 2015 08:13:01 + yawniek dl...@srtnwz.com wrote: On Friday, 7 August 2015 at 08:05:01 UTC, Daniel Kozák wrote: import std.zlib, std.file, std.stdio, std.conv; void main(string[] args) { auto f = File(args[1], rb); auto uncompressor = new

Re: zlib performance

2015-08-07 Thread Daniel Kozák via Digitalmars-d-learn
On Fri, 07 Aug 2015 08:13:01 + yawniek dl...@srtnwz.com wrote: On Friday, 7 August 2015 at 08:05:01 UTC, Daniel Kozák wrote: import std.zlib, std.file, std.stdio, std.conv; void main(string[] args) { auto f = File(args[1], rb); auto uncompressor = new

Re: zlib performance

2015-08-07 Thread Daniel Kozák via Digitalmars-d-learn
On Fri, 07 Aug 2015 07:19:43 + yawniek via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: hi, unpacking files is kinda slow, probably i'm doing something wrong. below code is about half the speed of gnu zcat on my os x machine. why? why do i need to .dup the buffer?

Re: zlib performance

2015-08-07 Thread Daniel Kozák via Digitalmars-d-learn
On Fri, 07 Aug 2015 07:36:39 + yawniek dl...@srtnwz.com wrote: On Friday, 7 August 2015 at 07:29:15 UTC, Daniel Kozák wrote: Which compiler and version. There has been some performance problem with IO on OSX, it should be fixed in 2.068 release i'm on master. v2.068-devel-8f81ffc

Re: zlib performance

2015-08-07 Thread Daniel Kozák via Digitalmars-d-learn
On Fri, 07 Aug 2015 07:19:43 + yawniek dl...@srtnwz.com wrote: hi, unpacking files is kinda slow, probably i'm doing something wrong. below code is about half the speed of gnu zcat on my os x machine. why? why do i need to .dup the buffer? It depends. In your case you don't need

Re: zlib performance

2015-08-07 Thread Daniel Kozák via Digitalmars-d-learn
On Fri, 07 Aug 2015 08:01:27 + yawniek dl...@srtnwz.com wrote: On Friday, 7 August 2015 at 07:48:25 UTC, yawniek wrote: On Friday, 7 August 2015 at 07:43:25 UTC, Daniel Kozák wrote: the fastest version i could come up so far is below. std.conv slows it down. going from a 4kb to a

Re: zlib performance

2015-08-07 Thread Daniel Kozák via Digitalmars-d-learn
On Fri, 7 Aug 2015 09:43:25 +0200 Daniel Kozák ko...@dlang.cz wrote: On Fri, 07 Aug 2015 07:36:39 + yawniek dl...@srtnwz.com wrote: On Friday, 7 August 2015 at 07:29:15 UTC, Daniel Kozák wrote: Which compiler and version. There has been some performance problem with IO on OSX,

Re: zlib performance

2015-08-07 Thread Daniel Kozák via Digitalmars-d-learn
On Fri, 07 Aug 2015 12:29:26 + yawniek dl...@srtnwz.com wrote: On Friday, 7 August 2015 at 11:45:00 UTC, Daniel Kozak wrote: On Friday, 7 August 2015 at 09:12:32 UTC, yawniek wrote: [...] Can you try it without write operation (comment out all write)? And than try it without

Re: Concurrency Confusion

2015-08-04 Thread Daniel Kozák via Digitalmars-d-learn
On Tue, 04 Aug 2015 10:29:55 + 岩倉 澪 mio.iwak...@gmail.com wrote: On Tuesday, 4 August 2015 at 08:35:10 UTC, Dicebot wrote: auto output = receiveOnly!(immutable(Bar)[]); Won't message passing like this result in an expensive copy No it will copy only struct containing length and

Re: Why approxEqual not working for integers in dmd 2068-b2

2015-07-28 Thread Daniel Kozák via Digitalmars-d-learn
On Tue, 28 Jul 2015 02:16:56 + lobo swampl...@gmail.com wrote: Hi all, I have a bunch of unittests for template code taking any numeric type. Because I'm lazy I just use the approxEqual for both floating point and integer comparisons in these tests. In DMD 2067.1 everthing

Re: Why approxEqual not working for integers in dmd 2068-b2

2015-07-28 Thread Daniel Kozák via Digitalmars-d-learn
On Tue, 28 Jul 2015 08:50:53 +0200 Daniel Kozák ko...@dlang.cz wrote: On Tue, 28 Jul 2015 02:16:56 + lobo swampl...@gmail.com wrote: I would say it is a compiler bug. consider this: bool some(real x, real y) { return true; } bool some(float x, float y) { return

Re: Why approxEqual not working for integers in dmd 2068-b2

2015-07-28 Thread Daniel Kozák via Digitalmars-d-learn
On Tue, 28 Jul 2015 02:16:56 + lobo swampl...@gmail.com wrote: Hi all, I have a bunch of unittests for template code taking any numeric type. Because I'm lazy I just use the approxEqual for both floating point and integer comparisons in these tests. In DMD 2067.1 everthing

Re: idiom for C error strings

2015-07-21 Thread Daniel Kozák via Digitalmars-d-learn
On Tue, 21 Jul 2015 12:27:55 + yawniek dl...@srtnwz.com wrote: whats the proper way to use/wrap C functions that expect a error string buffer e.g.: somefun(T param1, char* errstr, size_t errstr_size) in D ? dynamic: auto buf = new char[size]; somefun(param1, buf.ptr,

Re: Weird behavior of this in a subclass, I think?

2015-07-16 Thread Daniel Kozák via Digitalmars-d-learn
On Thu, 16 Jul 2015 00:18:30 + seashell86 via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: So I've been mostly just toying around with D as it seems like it will end up being a strong language for game development both now and even moreso in the future. That being said,

Re: How to use core.thread.Thread

2015-07-16 Thread Daniel Kozák via Digitalmars-d-learn
On Thu, 16 Jul 2015 07:57:10 + aki via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: I can't resolve the compile errors: import core.thread; class DerivedThread : Thread { int count = 0; this() { super(run); } private void run()

Re: Casting random type to random struct - is this a bug?

2015-07-15 Thread Daniel Kozák via Digitalmars-d-learn
On Wed, 15 Jul 2015 11:57:01 -0400 Steven Schveighoffer schvei...@yahoo.com wrote: On 7/15/15 11:45 AM, rumbu wrote: struct S { int a, b; } auto s = cast(S)10; //compiles and sets s.a to 10. It works also for any other type, if the structure contains a member of that type in the

Re: Casting random type to random struct - is this a bug?

2015-07-15 Thread Daniel Kozák via Digitalmars-d-learn
On Wed, 15 Jul 2015 15:45:43 + rumbu ru...@rumbu.ro wrote: struct S { int a, b; } auto s = cast(S)10; //compiles and sets s.a to 10. It works also for any other type, if the structure contains a member of that type in the first position. Is this normal behaviour? Yes, this is OK

Re: goroutines vs vibe.d tasks

2015-07-01 Thread Daniel Kozák via Digitalmars-d-learn
Same problem still extreamly slow On Wed, 01 Jul 2015 03:28:01 + rsw0x anonym...@anonymous.com wrote: On Tuesday, 30 June 2015 at 15:18:36 UTC, Jack Applegame wrote: Just creating a bunch (10k) of sleeping (for 100 msecs) goroutines/tasks. Compilers go: go version go1.4.2

Re: Bug or feature?

2015-06-30 Thread Daniel Kozák via Digitalmars-d-learn
On Mon, 29 Jun 2015 05:04:36 -0700 Jonathan M Davis via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: On Sunday, June 28, 2015 11:37:59 Jack Applegame via Digitalmars-d-learn wrote: I don't see any reason why it should not compile. import std.array; import std.range;

Re: Struct vs. Class

2015-06-26 Thread Daniel Kozák via Digitalmars-d-learn
On Fri, 26 Jun 2015 11:11:15 + Chris via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: I have still some classes lying around in my code. As threading is becoming more and more of an issue, classes and OOP in general turn out to be a nuisance. It's not so hard to turn the

Re: Struct vs. Class

2015-06-26 Thread Daniel Kozák via Digitalmars-d-learn
On Fri, 26 Jun 2015 11:11:15 + Chris via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: I have still some classes lying around in my code. As threading is becoming more and more of an issue, classes and OOP in general turn out to be a nuisance. It's not so hard to turn the

Re: Return types of the methods of a struct

2015-06-19 Thread Daniel Kozák via Digitalmars-d-learn
On Fri, 19 Jun 2015 13:52:52 + Quentin Ladeveze via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: On Friday, 19 June 2015 at 13:38:45 UTC, Steven Schveighoffer wrote: Does this work for you, or is there a further expectation? auto asTuple() { return Tuple!(int, a,

Re: How to avoid multiple spelling `import`

2015-06-16 Thread Daniel Kozák via Digitalmars-d-learn
On Tue, 16 Jun 2015 11:45:22 + Dennis Ritchie via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: Maybe not everyone needs these features. But, unfortunately, I often use a lot of imported modules. And use every time the word `import` very bad. version (none) { import

Re: Calling a cpp function from d

2015-06-16 Thread Daniel Kozák via Digitalmars-d-learn
On Tue, 16 Jun 2015 13:01:09 + via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: On Tuesday, 16 June 2015 at 12:42:16 UTC, C2D wrote: On Tuesday, 16 June 2015 at 12:31:23 UTC, John Chapman wrote: On Tuesday, 16 June 2015 at 12:26:45 UTC, C2D wrote: BOOL result =

Re: Calling a cpp function from d

2015-06-16 Thread Daniel Kozák via Digitalmars-d-learn
On Tue, 16 Jun 2015 12:26:45 + C2D via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: Hi, I encountered the following error: Error: function files.SHGetFolderPath (void* hwndOwner, int nFolder, void* hToken, uint dwFlags, char* pszPath) is not callable using argument

Re: Encapsulate return value in scoped

2015-06-11 Thread Daniel Kozák via Digitalmars-d-learn
On Thu, 11 Jun 2015 09:01:04 + Yuxuan Shui via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: A x = scoped!A(10); use auto x = scoped!A(10);

Re: Shortest way to allocate an array and initialize it with a specific value.

2015-06-11 Thread Daniel Kozák via Digitalmars-d-learn
On Thu, 11 Jun 2015 11:43:25 + via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: On Thursday, 11 June 2015 at 08:33:46 UTC, Daniel Kozák wrote: On Wed, 10 Jun 2015 20:22:17 + Adel Mamin via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: ubyte[5]

Re: Shortest way to allocate an array and initialize it with a specific value.

2015-06-11 Thread Daniel Kozák via Digitalmars-d-learn
On Wed, 10 Jun 2015 20:22:17 + Adel Mamin via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: ubyte[5] a = 0xAA; // Fine. Five 0xAA bytes. auto a2 = new ubyte[5]; // Fine. Five 0 bytes. Now, let's say, I want to allocate an array of a size, derived at run time, and

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

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 digitalmars-d-learn@puremagic.com wrote: I am writing a echoclient, as below: Ptr!Conn conn = connect(127.0.0.1,8881); ubyte[100] buf; for(int i=0; iN; i++) { scope string str = format(%s,i);

Re: Template type deduction and specialization

2015-05-21 Thread Daniel Kozák via Digitalmars-d-learn
On Wed, 20 May 2015 17:23:05 -0700 Ali Çehreli via Digitalmars-d-learn digitalmars-d-learn@puremagic.com 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` ;-) OK, if that's the

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 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 Çehreli via Digitalmars-d-learn digitalmars-d-learn

Re: Template type deduction and specialization

2015-05-21 Thread Daniel Kozák via Digitalmars-d-learn
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 Çehreli via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: On 05/20/2015 04:10 PM, Mike Parker wrote

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 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) { writeln(t); } void printVal(T : T*)(T* t) {

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 digitalmars-d-learn@puremagic.com wrote: On Wednesday, 20 May 2015 at 09:35:43 UTC, Daniel Kozak wrote: DOCS: http://dlang.org/template.html#function-templates says:

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

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 digitalmars-d-learn@puremagic.com wrote: [code] import std.stdio; class Connection{ private void other() shared{} public void close() shared{ synchronized( this ){ other();

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

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

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

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 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 wrote: On Thu, 07 May 2015 10:33:44 + Vadim Lopatin via

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 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; s.foo2!T(j); return s; } }

Re: Printing an std.container.Array

2015-04-17 Thread Daniel Kozák via Digitalmars-d-learn
On Thu, 16 Apr 2015 20:18:40 + Panke via Digitalmars-d-learn digitalmars-d-learn@puremagic.com 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

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 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 void* into something I can process in D? //I have the

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 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 void* into something I can process in D? //I have the

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 digitalmars-d-learn@puremagic.com wrote: I have written a function as follows: public bool setCookie( string name, string value, long maxAgeInSeconds = long.min, string expiresOnGMTDate=null,

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

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

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

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

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

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

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

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

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

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

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 digitalmars-d-learn@puremagic.com napsáno: I have written the following code: test.d == import core.thread; import std.stdio; void threadFunc(){ writeln(Thread func); } public static

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 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: test.d == import core.thread; import std.stdio; void

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

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

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

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

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

  1   2   >