Re: How about use Gc as a big memory pool?

2016-04-07 Thread Olivier Pisano via Digitalmars-d-learn
On Friday, 8 April 2016 at 03:27:04 UTC, Dsby wrote: when the soft start, call GC.disable(). use "new " create a class , struct or a array. and use destory(T/void *) to call the ~this(), then GC.free to free the memory, and use RAII in class or Struct. And user the Timer, or in some where to

How about use Gc as a big memory pool?

2016-04-07 Thread Dsby via Digitalmars-d-learn
when the soft start, call GC.disable(). use "new " create a class , struct or a array. and use destory(T/void *) to call the ~this(), then GC.free to free the memory, and use RAII in class or Struct. And user the Timer, or in some where to call : GC.enable(), GC.collect(), GC.disable(); In

Re: is std.algorithm.joiner lazy?

2016-04-07 Thread Puming via Digitalmars-d-learn
On Friday, 8 April 2016 at 02:49:01 UTC, Jonathan M Davis wrote: [...] Thanks. I'll adopt this idiom. Hopefully it gets used often enough to warrent a phobos function :-)

Re: @nogc inconsistent for array comparison depending on mutability of elements

2016-04-07 Thread Xinok via Digitalmars-d-learn
On Friday, 8 April 2016 at 01:36:18 UTC, rcorre wrote: @nogc unittest { int[2] a = [1, 2]; assert(a == [1, 2]); // OK immutable(int)[2] b = [1, 2]; assert(b == [1, 2]); // fail: array literal may cause allocation } Is there any logic behind allowing the comparison with `a`

Re: Unexpected Crash

2016-04-07 Thread default0 via Digitalmars-d-learn
On Thursday, 7 April 2016 at 21:22:19 UTC, Ali Çehreli wrote: On 04/07/2016 01:49 PM, default0 wrote: On Thursday, 7 April 2016 at 20:47:35 UTC, Adam D. Ruppe wrote: On Thursday, 7 April 2016 at 20:42:17 UTC, default0 wrote: If I enter "5,5,5" on the commandline, hit enter, then enter "5,5,5"

Re: is std.algorithm.joiner lazy?

2016-04-07 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, April 08, 2016 02:01:07 Puming via Digitalmars-d-learn wrote: > So what you mean is to read the front in constructor, and read > further parts in the popFront()? that way multiple access to the > front won't hurt anything. I think it might work, I'll change my > code. > > So the

Re: how to parse a string into a phobos datatype with additional logic

2016-04-07 Thread Puming via Digitalmars-d-learn
On Thursday, 7 April 2016 at 11:07:35 UTC, Marc Schütz wrote: On Thursday, 7 April 2016 at 08:06:03 UTC, Puming wrote: On Thursday, 7 April 2016 at 07:45:06 UTC, yawniek wrote: what is the way one is supposed to parse e.g. a double of unixtime (as delived by nginx logs) into a SysTime?

Re: is std.algorithm.joiner lazy?

2016-04-07 Thread Puming via Digitalmars-d-learn
On Friday, 8 April 2016 at 01:14:11 UTC, Jonathan M Davis wrote: [...] Well, given your example, I would strongly argue that you should write a range that calls read in its constructor and in popFront rather (so that calling front multiple times doesn't matter) rather than using map. While

Re: is std.algorithm.joiner lazy?

2016-04-07 Thread Puming via Digitalmars-d-learn
On Friday, 8 April 2016 at 01:14:11 UTC, Jonathan M Davis wrote: [...] Lazy means that it's not going to consume the entire range when you call the function. Rather, it's going to return a range that you can iterate over. It may or may not process the first element before returning,

@nogc inconsistent for array comparison depending on mutability of elements

2016-04-07 Thread rcorre via Digitalmars-d-learn
@nogc unittest { int[2] a = [1, 2]; assert(a == [1, 2]); // OK immutable(int)[2] b = [1, 2]; assert(b == [1, 2]); // fail: array literal may cause allocation } Is there any logic behind allowing the comparison with `a` but not `b`, or is this a compiler bug?

Re: is std.algorithm.joiner lazy?

2016-04-07 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, April 08, 2016 00:30:05 Puming via Digitalmars-d-learn wrote: > On Thursday, 7 April 2016 at 18:15:07 UTC, Jonathan M Davis wrote: > > On Thursday, April 07, 2016 08:47:15 Puming via > > > > Digitalmars-d-learn wrote: > >> On Thursday, 7 April 2016 at 08:27:23 UTC, Edwin van Leeuwen >

Re: is std.algorithm.joiner lazy?

2016-04-07 Thread Puming via Digitalmars-d-learn
On Thursday, 7 April 2016 at 18:15:07 UTC, Jonathan M Davis wrote: On Thursday, April 07, 2016 08:47:15 Puming via Digitalmars-d-learn wrote: On Thursday, 7 April 2016 at 08:27:23 UTC, Edwin van Leeuwen wrote: > On Thursday, 7 April 2016 at 08:17:38 UTC, Puming wrote: >> On Thursday, 7 April

Re: __traits(compiles) and template instantiation

2016-04-07 Thread jkpl via Digitalmars-d-learn
On Thursday, 7 April 2016 at 21:36:37 UTC, Alex Parrill wrote: On Thursday, 7 April 2016 at 20:31:12 UTC, jmh530 wrote: I've been playing around with __traits and I find myself confused on one aspect. In the code below, I was testing whether some templates would compile given types. For the

Re: __traits(compiles) and template instantiation

2016-04-07 Thread Alex Parrill via Digitalmars-d-learn
On Thursday, 7 April 2016 at 20:31:12 UTC, jmh530 wrote: I've been playing around with __traits and I find myself confused on one aspect. In the code below, I was testing whether some templates would compile given types. For the most part it works as I would expect. I think I get why the

Re: Unexpected Crash

2016-04-07 Thread Ali Çehreli via Digitalmars-d-learn
On 04/07/2016 01:49 PM, default0 wrote: On Thursday, 7 April 2016 at 20:47:35 UTC, Adam D. Ruppe wrote: On Thursday, 7 April 2016 at 20:42:17 UTC, default0 wrote: If I enter "5,5,5" on the commandline, hit enter, then enter "5,5,5" When you hit enter, that puts a \n character in the buffer.

Re: Unexpected Crash

2016-04-07 Thread default0 via Digitalmars-d-learn
On Thursday, 7 April 2016 at 20:47:35 UTC, Adam D. Ruppe wrote: On Thursday, 7 April 2016 at 20:42:17 UTC, default0 wrote: If I enter "5,5,5" on the commandline, hit enter, then enter "5,5,5" When you hit enter, that puts a \n character in the buffer. readf doesn't skip that automatically,

Re: Get VTable pointer as a constant

2016-04-07 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 7 April 2016 at 20:43:04 UTC, Johan Engelen wrote: Does anybody know how to get the class's vtable pointer without doing a memory read? I don't think you can... why do you want it though?

Re: Unexpected Crash

2016-04-07 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 7 April 2016 at 20:42:17 UTC, default0 wrote: If I enter "5,5,5" on the commandline, hit enter, then enter "5,5,5" When you hit enter, that puts a \n character in the buffer. readf doesn't skip that automatically, so it complains upon hitting that newline (the error message

Get VTable pointer as a constant

2016-04-07 Thread Johan Engelen via Digitalmars-d-learn
I am trying to get the vtable pointer as a constant (!). I've found auto vptr = typeid(A).vtbl.ptr gets me the pointer, but because TypeInfo is not immutable (another forum thread), this will read the pointer from memory instead of loading a direct value. Does anybody know how to get the

Unexpected Crash

2016-04-07 Thread default0 via Digitalmars-d-learn
Consider the following program: import std.stdio; void main(string[] args) { int a, b, c; while(true) { readf("%d,%d,%d", , , ); writeln(a, b, c); } } If I enter "5,5,5" on the commandline, hit enter, then enter "5,5,5" a second time, hit enter again, the second

__traits(compiles) and template instantiation

2016-04-07 Thread jmh530 via Digitalmars-d-learn
I've been playing around with __traits and I find myself confused on one aspect. In the code below, I was testing whether some templates would compile given types. For the most part it works as I would expect. I think I get why the third one works with foo!(int). My guess is that it assumed

Re: how to parse a string into a phobos datatype with additional logic

2016-04-07 Thread Ali Çehreli via Digitalmars-d-learn
On 04/07/2016 11:35 AM, Ali Çehreli wrote: On 04/07/2016 11:29 AM, Jonathan M Davis via Digitalmars-d-learn wrote: On Thursday, April 07, 2016 07:45:06 yawniek via Digitalmars-d-learn wrote: what is the way one is supposed to parse e.g. a double of unixtime (as delived by nginx logs) into a

Re: how to parse a string into a phobos datatype with additional logic

2016-04-07 Thread yawniek via Digitalmars-d-learn
On Thursday, 7 April 2016 at 18:29:19 UTC, Jonathan M Davis wrote: On Thursday, April 07, 2016 07:45:06 yawniek via Digitalmars-d-learn wrote: So, while I understand your frustration, I just don't see any other sane way to approach this problem than what you've done. Putting it all in a

Re: how to parse a string into a phobos datatype with additional logic

2016-04-07 Thread Ali Çehreli via Digitalmars-d-learn
On 04/07/2016 11:29 AM, Jonathan M Davis via Digitalmars-d-learn wrote: On Thursday, April 07, 2016 07:45:06 yawniek via Digitalmars-d-learn wrote: what is the way one is supposed to parse e.g. a double of unixtime (as delived by nginx logs) into a SysTime? currently i'm creating a wrapper

Re: how to parse a string into a phobos datatype with additional logic

2016-04-07 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, April 07, 2016 07:45:06 yawniek via Digitalmars-d-learn wrote: > what is the way one is supposed to parse e.g. a > double of unixtime (as delived by nginx logs) into a SysTime? > > currently i'm creating a wrapper struct around SysTime with alias > this as: > >

Re: is std.algorithm.joiner lazy?

2016-04-07 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, April 07, 2016 08:47:15 Puming via Digitalmars-d-learn wrote: > On Thursday, 7 April 2016 at 08:27:23 UTC, Edwin van Leeuwen > > wrote: > > On Thursday, 7 April 2016 at 08:17:38 UTC, Puming wrote: > >> On Thursday, 7 April 2016 at 08:07:12 UTC, Edwin van Leeuwen > >> wrote: > >> > >>

Re: How to set padding for base64 encoding

2016-04-07 Thread ag0aep6g via Digitalmars-d-learn
On 07.04.2016 14:57, rikki cattermole wrote: Ugh, 2.070.2 definitely has it still. I have no idea when that changed I don't think """...""" ever was a thing. You could definitely put newlines in normal "..." literals since basically forever. And concatenation of adjacent "..." literals

Re: Best properly way to destroy a 2 dimensional array?

2016-04-07 Thread Steven Schveighoffer via Digitalmars-d-learn
On 4/6/16 3:54 PM, Jonathan Villa wrote: I wrote a little program that given some number it generates a list of different combinations (represented by a ubyte array), so in the end my function with name GenerateCombinations(int x) returns a ubyte[][] (list of arrays of ubytes). Now the problem

Re: Best properly way to destroy a 2 dimensional array?

2016-04-07 Thread Jonathan Villa via Digitalmars-d-learn
On Thursday, 7 April 2016 at 10:05:02 UTC, Andrea Fontana wrote: On Thursday, 7 April 2016 at 10:02:05 UTC, Andrea Fontana wrote: On Wednesday, 6 April 2016 at 20:30:33 UTC, Jonathan Villa wrote: Anything change if you wrap your code like: while ... { ... { ubyte[][] ... ...

Re: Issue with 2.071: Regression or valid error?

2016-04-07 Thread Steven Schveighoffer via Digitalmars-d-learn
On 4/6/16 11:10 AM, Andre wrote: Hi, With 2.071 following coding does not compile anymore and somehow I feel it should compile. The issue is with line "cat.create();". Cat is a sub type of Animal. Animal "owns" method create and I want to call the method create within the class Animal for cat.

Re: Get third part of front-end version number

2016-04-07 Thread Steven Schveighoffer via Digitalmars-d-learn
On 4/5/16 2:11 PM, Johan Engelen wrote: On Tuesday, 5 April 2016 at 18:01:05 UTC, Nick Sabalausky wrote: These days, DMD/DMDFE version numbers are three parts, ex: 2.070.1. I can get the first two via std.compiler.version_major and std.compiler.version_minor. Is there a way to get the third

Re: VibeCustomMain not working

2016-04-07 Thread yawniek via Digitalmars-d-learn
On Thursday, 7 April 2016 at 13:40:17 UTC, Rene Zwanenburg wrote: On Thursday, 7 April 2016 at 13:25:29 UTC, Jerry wrote: I generated a visuald project and tried that. Now suddenly it is working as expected. So I guess it's a bug in dub. That's possible of course, but I'd expect something so

Re: VibeCustomMain not working

2016-04-07 Thread Rene Zwanenburg via Digitalmars-d-learn
On Thursday, 7 April 2016 at 13:40:17 UTC, Rene Zwanenburg wrote: That's possible of course, but I'd expect something so fundamental breaking to be noticed sooner. Just to make sure, could you run dub with --force to rule out that it's picking up some stale object files from somewhere? And

Re: VibeCustomMain not working

2016-04-07 Thread Rene Zwanenburg via Digitalmars-d-learn
On Thursday, 7 April 2016 at 13:25:29 UTC, Jerry wrote: I generated a visuald project and tried that. Now suddenly it is working as expected. So I guess it's a bug in dub. That's possible of course, but I'd expect something so fundamental breaking to be noticed sooner. Just to make sure,

Re: VibeCustomMain not working

2016-04-07 Thread Jerry via Digitalmars-d-learn
On Thursday, 7 April 2016 at 13:17:32 UTC, Jerry wrote: On Thursday, 7 April 2016 at 13:13:14 UTC, Suliman wrote: dup upgdare dub upgdare Tried that. I have to say this is odd. I generated a visuald project and tried that. Now suddenly it is working as expected. So I guess it's a bug in

Re: VibeCustomMain not working

2016-04-07 Thread Suliman via Digitalmars-d-learn
dup upgdare dub upgdare

Re: VibeCustomMain not working

2016-04-07 Thread Jerry via Digitalmars-d-learn
On Thursday, 7 April 2016 at 13:13:14 UTC, Suliman wrote: dup upgdare dub upgdare Tried that. I have to say this is odd.

Re: VibeCustomMain not working

2016-04-07 Thread Suliman via Digitalmars-d-learn
On Thursday, 7 April 2016 at 12:01:59 UTC, Jerry wrote: Hello, I am trying to use vibe with DMD 2.67, dub and windows. But in some way the default main function is sneaking in my build system even when I'm using VibeCustomMain version. Main file: import vibe.vibe; void main() {

Re: How to set padding for base64 encoding

2016-04-07 Thread Suliman via Digitalmars-d-learn
On Thursday, 7 April 2016 at 12:43:54 UTC, rikki cattermole wrote: On 08/04/2016 12:39 AM, Suliman wrote: On Thursday, 7 April 2016 at 12:30:59 UTC, rikki cattermole wrote: On 08/04/2016 12:19 AM, Kagamin wrote: Create a range that would remove the newline characters from string, then decode

Re: How to set padding for base64 encoding

2016-04-07 Thread rikki cattermole via Digitalmars-d-learn
On 08/04/2016 12:52 AM, ag0aep6g wrote: On 07.04.2016 13:59, rikki cattermole wrote: "abc" strings are not multiline. Use """abc""" for that purpose. Wat. We're talking about, aren't we? In D, "abc" strings are multiline, and """abc""" is not a thing. `"""abc"""` is the same as `"" "abc" ""`

Re: is std.algorithm.joiner lazy?

2016-04-07 Thread Puming via Digitalmars-d-learn
On Thursday, 7 April 2016 at 10:57:25 UTC, Edwin van Leeuwen wrote: On Thursday, 7 April 2016 at 09:55:56 UTC, Puming wrote: [...] That seems like a bug to me and you might want to submit it to the bug tracker. Even converting it to an array first does not seem to work: [...] Thanks. I

How to convert PostgreSQL bytea HEX value to byte[] ?

2016-04-07 Thread Suliman via Digitalmars-d-learn
I need to extract binary blob from PostgreSQL. It's input/output by default work in hex mode. http://www.postgresql.org/docs/current/static/datatype-binary.html I need to extract data and write them on FS as normal file (byte [] I suppose). Here is my question on SO

Re: How to set padding for base64 encoding

2016-04-07 Thread ag0aep6g via Digitalmars-d-learn
On 07.04.2016 13:59, rikki cattermole wrote: "abc" strings are not multiline. Use """abc""" for that purpose. Wat. We're talking about, aren't we? In D, "abc" strings are multiline, and """abc""" is not a thing. `"""abc"""` is the same as `"" "abc" ""` is the same as `"" ~ "abc" ~ ""` is the

Re: How to set padding for base64 encoding

2016-04-07 Thread rikki cattermole via Digitalmars-d-learn
On 08/04/2016 12:39 AM, Suliman wrote: On Thursday, 7 April 2016 at 12:30:59 UTC, rikki cattermole wrote: On 08/04/2016 12:19 AM, Kagamin wrote: Create a range that would remove the newline characters from string, then decode from that. Can confirm, its \n and \r that is causing the problems

Re: How to set padding for base64 encoding

2016-04-07 Thread Suliman via Digitalmars-d-learn
On Thursday, 7 April 2016 at 12:30:59 UTC, rikki cattermole wrote: On 08/04/2016 12:19 AM, Kagamin wrote: Create a range that would remove the newline characters from string, then decode from that. Can confirm, its \n and \r that is causing the problems here. with:

Re: How to set padding for base64 encoding

2016-04-07 Thread rikki cattermole via Digitalmars-d-learn
On 08/04/2016 12:19 AM, Kagamin wrote: Create a range that would remove the newline characters from string, then decode from that. Can confirm, its \n and \r that is causing the problems here.

Re: How to set padding for base64 encoding

2016-04-07 Thread Andrea Fontana via Digitalmars-d-learn
On Thursday, 7 April 2016 at 12:24:06 UTC, Suliman wrote: On Thursday, 7 April 2016 at 12:19:48 UTC, Kagamin wrote: Create a range that would remove the newline characters from string, then decode from that. std.file.write("output.png", Base64.decode(myimg.chomp)); The same error Anyway if

Re: How to set padding for base64 encoding

2016-04-07 Thread Kagamin via Digitalmars-d-learn
chomp only trims the string at the beginning and at the end, not in the middle.

Profile ldc2

2016-04-07 Thread jmh530 via Digitalmars-d-learn
I like how dmd has the -profile switch, but I'm not sure how to go about profiling ldc2. I don't see any compiler flags in the -help. I'm also using Windows, if that matters, but if the best options are on Linux, I can dual-boot.

Re: How to set padding for base64 encoding

2016-04-07 Thread Suliman via Digitalmars-d-learn
On Thursday, 7 April 2016 at 12:19:48 UTC, Kagamin wrote: Create a range that would remove the newline characters from string, then decode from that. std.file.write("output.png", Base64.decode(myimg.chomp)); The same error

Re: How to set padding for base64 encoding

2016-04-07 Thread Kagamin via Digitalmars-d-learn
Create a range that would remove the newline characters from string, then decode from that.

Re: How to set padding for base64 encoding

2016-04-07 Thread Suliman via Digitalmars-d-learn
On Thursday, 7 April 2016 at 11:59:09 UTC, rikki cattermole wrote: On 07/04/2016 11:49 PM, Suliman wrote: It's look like my data have padding that cause crush on function: std.file.write("output.png", Base64.decode(myimg)); Invalid character: It's look like I should to use template

VibeCustomMain not working

2016-04-07 Thread Jerry via Digitalmars-d-learn
Hello, I am trying to use vibe with DMD 2.67, dub and windows. But in some way the default main function is sneaking in my build system even when I'm using VibeCustomMain version. Main file: import vibe.vibe; void main() { writeln("Hello world"); } And dub file: { "targetType":

Re: How to set padding for base64 encoding

2016-04-07 Thread rikki cattermole via Digitalmars-d-learn
On 07/04/2016 11:49 PM, Suliman wrote: It's look like my data have padding that cause crush on function: std.file.write("output.png", Base64.decode(myimg)); Invalid character: It's look like I should to use template function, but I can't figure out how to use it. Could anybody show example?

How to set padding for base64 encoding

2016-04-07 Thread Suliman via Digitalmars-d-learn
It's look like my data have padding that cause crush on function: std.file.write("output.png", Base64.decode(myimg)); Invalid character: It's look like I should to use template function, but I can't figure out how to use it. Could anybody show example? My code:

Re: how to parse a string into a phobos datatype with additional logic

2016-04-07 Thread yawniek via Digitalmars-d-learn
On Thursday, 7 April 2016 at 08:03:34 UTC, Edwin van Leeuwen wrote: You can try this library: https://code.dlang.org/packages/dateparser nope this will not work and the question is broader: i want to have a standard datatype parsed in a specific way and so that i can use other std library

Re: how to parse a string into a phobos datatype with additional logic

2016-04-07 Thread Marc Schütz via Digitalmars-d-learn
On Thursday, 7 April 2016 at 08:06:03 UTC, Puming wrote: On Thursday, 7 April 2016 at 07:45:06 UTC, yawniek wrote: what is the way one is supposed to parse e.g. a double of unixtime (as delived by nginx logs) into a SysTime? currently i'm creating a wrapper struct around SysTime with alias

Re: is std.algorithm.joiner lazy?

2016-04-07 Thread Edwin van Leeuwen via Digitalmars-d-learn
On Thursday, 7 April 2016 at 09:55:56 UTC, Puming wrote: When compiled, I get the error: Error: open path skips field __caches_field_0 source/app.d(19, 36): Error: template instance std.algorithm.iteration.cache!(MapResult!(__lambda1, int[])) error instantiating That seems like a bug to me

Re: Best properly way to destroy a 2 dimensional array?

2016-04-07 Thread Andrea Fontana via Digitalmars-d-learn
On Thursday, 7 April 2016 at 10:02:05 UTC, Andrea Fontana wrote: On Wednesday, 6 April 2016 at 20:30:33 UTC, Jonathan Villa wrote: On Wednesday, 6 April 2016 at 19:54:32 UTC, Jonathan Villa wrote: I wrote a little program that given some number it generates a TL;DR: My program generates a

Re: Best properly way to destroy a 2 dimensional array?

2016-04-07 Thread Andrea Fontana via Digitalmars-d-learn
On Wednesday, 6 April 2016 at 20:30:33 UTC, Jonathan Villa wrote: On Wednesday, 6 April 2016 at 19:54:32 UTC, Jonathan Villa wrote: I wrote a little program that given some number it generates a TL;DR: My program generates a very large `ubyte[][]`, and after I call destroy and GC.collect()

Re: is std.algorithm.joiner lazy?

2016-04-07 Thread Puming via Digitalmars-d-learn
On Thursday, 7 April 2016 at 08:27:23 UTC, Edwin van Leeuwen wrote: On Thursday, 7 April 2016 at 08:17:38 UTC, Puming wrote: On Thursday, 7 April 2016 at 08:07:12 UTC, Edwin van Leeuwen wrote: OK. Even if it consumes the first two elements, then why does it have to consume them AGAIN when

Re: is std.algorithm.joiner lazy?

2016-04-07 Thread Puming via Digitalmars-d-learn
On Thursday, 7 April 2016 at 08:27:23 UTC, Edwin van Leeuwen wrote: On Thursday, 7 April 2016 at 08:17:38 UTC, Puming wrote: On Thursday, 7 April 2016 at 08:07:12 UTC, Edwin van Leeuwen wrote: OK. Even if it consumes the first two elements, then why does it have to consume them AGAIN when

Re: is std.algorithm.joiner lazy?

2016-04-07 Thread Edwin van Leeuwen via Digitalmars-d-learn
On Thursday, 7 April 2016 at 08:17:38 UTC, Puming wrote: On Thursday, 7 April 2016 at 08:07:12 UTC, Edwin van Leeuwen wrote: OK. Even if it consumes the first two elements, then why does it have to consume them AGAIN when actually used? If the function mkarray has side effects, it could lead

Re: is std.algorithm.joiner lazy?

2016-04-07 Thread Puming via Digitalmars-d-learn
On Thursday, 7 April 2016 at 08:07:12 UTC, Edwin van Leeuwen wrote: On Thursday, 7 April 2016 at 07:07:40 UTC, Puming wrote: [...] Apparently it works processing the first two elements at creation. All the other elements will be processed lazily. Even when a range is lazy the algorithm

Re: is std.algorithm.joiner lazy?

2016-04-07 Thread Edwin van Leeuwen via Digitalmars-d-learn
On Thursday, 7 April 2016 at 07:07:40 UTC, Puming wrote: Hi: when I use map with joiner, I found that function in map are called. In the document it says joiner is lazy, so why is the function called? say: int[] mkarray(int a) { writeln("mkarray called!"); return [a * 2]; // just for

Re: how to parse a string into a phobos datatype with additional logic

2016-04-07 Thread Puming via Digitalmars-d-learn
On Thursday, 7 April 2016 at 07:45:06 UTC, yawniek wrote: what is the way one is supposed to parse e.g. a double of unixtime (as delived by nginx logs) into a SysTime? currently i'm creating a wrapper struct around SysTime with alias this as:

Re: how to parse a string into a phobos datatype with additional logic

2016-04-07 Thread Edwin van Leeuwen via Digitalmars-d-learn
On Thursday, 7 April 2016 at 07:45:06 UTC, yawniek wrote: what is the way one is supposed to parse e.g. a double of unixtime (as delived by nginx logs) into a SysTime? currently i'm creating a wrapper struct around SysTime with alias this as:

how to parse a string into a phobos datatype with additional logic

2016-04-07 Thread yawniek via Digitalmars-d-learn
what is the way one is supposed to parse e.g. a double of unixtime (as delived by nginx logs) into a SysTime? currently i'm creating a wrapper struct around SysTime with alias this as: https://gist.github.com/yannick/6caf5a5184beea0c24f35d9d4a4c7783 really ugly imho. is there a better way

is std.algorithm.joiner lazy?

2016-04-07 Thread Puming via Digitalmars-d-learn
Hi: when I use map with joiner, I found that function in map are called. In the document it says joiner is lazy, so why is the function called? say: int[] mkarray(int a) { writeln("mkarray called!"); return [a * 2]; // just for test } void main() { auto xs = [1, 2]; auto r =