Re: How to foreach over a DList?

2014-03-31 Thread monarch_dodra
On Tuesday, 1 April 2014 at 04:43:44 UTC, H. S. Teoh wrote: On Mon, Mar 31, 2014 at 09:55:01PM +, monarch_dodra wrote: On Monday, 31 March 2014 at 21:41:16 UTC, H. S. Teoh wrote: >Argh, why is opSlice non-const? :-( Please file a bug. If opSlice was const, then you'd get a const slice, wit

Re: template interface and delegates

2014-03-31 Thread anonymous
Ok, thought i did something wrong or got some wrong idea how it should work.

Re: Why is SysTime.init invalid?

2014-03-31 Thread ed
OK, lazy me just read the std.satetime article again. It appears the design is for no invalid values and it is currently a known limitation due to CTFE. --- d_time_nan There is no equivalent. SysTime.init, which has a null TimeZone object, would be the closest, but once CTFE advances to the

Re: How to foreach over a DList?

2014-03-31 Thread Jeroen Bollen
Still no luck: import std.container; import std.stdio; void main() { DList!ubyte list1 = DList!ubyte(); list1 ~= cast(ubyte) 1; list1 ~= cast(ubyte) 2; list1 ~= cast(ubyte) 3; foreach(ubyte item; list1[]) { writeln(item); } } /usr

Why is SysTime.init invalid?

2014-03-31 Thread ed
Hi All, I'm trying to use SysTime in a struct but I've noticed the following: (A) SysTime.init leads to a crash. --- void main() { SysTime t; writefln("t:%s", t); } % ./dtest zsh: segmentation fault (core dumped) ./dtest --- (B) Initialising a SysTime member directly fails --- struc

Re: How to foreach over a DList?

2014-03-31 Thread H. S. Teoh
On Mon, Mar 31, 2014 at 09:55:01PM +, monarch_dodra wrote: > On Monday, 31 March 2014 at 21:41:16 UTC, H. S. Teoh wrote: > >Argh, why is opSlice non-const? :-( Please file a bug. > > If opSlice was const, then you'd get a const slice, with const > reference. You wouldn't even be able to iter

Kitchen Designer Hertfordshire

2014-03-31 Thread singsing
Kitchen Designer Hertfordshire. Thirty Ex Display Kitchens To Clear. w.w.w-e.x.d.i.s.p.l.a.y.k.i.t.c.h.e.n.s.1-c.o-u.k. .£ 5.9.5. Each with appliances.

Re: How to set JSON_TYPE in 2.0.65

2014-03-31 Thread Tolga Cakiroglu
I believe for this case you would want this: JSONValue oJson = [ "myEntry": "MyText" ]; Yeah, and unfortunately, there is no that easy way to create an empty "object" type json value though. (Yes, I had a need for that). I needed to work around of that.

Re: How to set JSON_TYPE in 2.0.65

2014-03-31 Thread Colden Cullen
On Monday, 31 March 2014 at 19:05:11 UTC, Matt Soucy wrote: On 03/31/2014 02:59 PM, nrgyzer wrote: Hi guys, I updated my dmd version from 2.0.63 to 2.0.65 and having some trouble with my JSON-definitions. The code below worked in 2.0.63 but not in 2.0.65: JSONValue oJson = JSONValue(); oJso

Re: Trying Multiple Aggregate reduce

2014-03-31 Thread Ali Çehreli
On 03/31/2014 04:01 PM, bearophile wrote: Ali Çehreli: statement.c:274: ErrorStatement::ErrorStatement(): Assertion `global.gaggedErrors || global.errors' failed. It's a little compiler bug, that should go in Bugzilla (even if perhaps it was recently added). https://d.puremagic.com/issues

Re: Trying Multiple Aggregate reduce

2014-03-31 Thread bearophile
Ali Çehreli: statement.c:274: ErrorStatement::ErrorStatement(): Assertion `global.gaggedErrors || global.errors' failed. It's a little compiler bug, that should go in Bugzilla (even if perhaps it was recently added). Bye, bearophile

Re: How to foreach over a DList?

2014-03-31 Thread anonymous
On Monday, 31 March 2014 at 21:55:03 UTC, monarch_dodra wrote: If opSlice was const, then you'd get a const slice, with const reference. You wouldn't even be able to iterate on it. const opSlice does not mean it returns a const(Range). With some extra code, you could create some sort of "slice

Re: Trying Multiple Aggregate reduce

2014-03-31 Thread Nordlöw
You can't use reduce with a const seed. This, surely, must be a compiler bug right? /Per

Re: Trying Multiple Aggregate reduce

2014-03-31 Thread Ali Çehreli
On 03/31/2014 03:13 PM, bearophile wrote: Nordlöw: I'm trying to figure out how to use reduce with multiply funs. Could someone please check the following. It looks like a compiler bug on git head (DMD64 D Compiler v2.066-devel-75159e4): import std.algorithm; int foo(int value) { retu

Re: Trying Multiple Aggregate reduce

2014-03-31 Thread bearophile
Nordlöw: I'm trying to figure out how to use reduce with multiply funs. import std.algorithm: min, max, reduce; import std.typecons: tuple, Unqual; import std.range: isInputRange, ElementType; /// Returns: Tuple of Minmum and Maximum Element in X. auto minMax(alias F = min, alias G = max, R)(

Re: How to foreach over a DList?

2014-03-31 Thread Jos van Uden
On 31-3-2014 19:50, Jeroen Bollen wrote: I am trying to foreach over a std.container.DList but it isn't working. I have tried the following code: https://gist.github.com/Binero/f30e56351baf05f1a2ec I am getting the following errors: /usr/include/dlang/dmd/std/container.d(1925): Error: template

Trying Multiple Aggregate reduce

2014-03-31 Thread Nordlöw
I'm trying to figure out how to use reduce with multiply funs. Here's my try on minmaxElement: import std.typecons: tuple; /** Returns: Tuple of Minmum and Maximum Element in X. */ auto minmaxElement(alias F = min, alias G = max, R)(in R range) @safe pure nothrow if (isInputRange!R) {

Re: How to foreach over a DList?

2014-03-31 Thread monarch_dodra
On Monday, 31 March 2014 at 21:41:16 UTC, H. S. Teoh wrote: Argh, why is opSlice non-const? :-( Please file a bug. If opSlice was const, then you'd get a const slice, with const reference. You wouldn't even be able to iterate on it. With some extra code, you could create some sort of "slice

Re: How to foreach over a DList?

2014-03-31 Thread Ali Çehreli
On 03/31/2014 10:50 AM, Jeroen Bollen wrote: I am trying to foreach over a std.container.DList but it isn't working. I have tried the following code: https://gist.github.com/Binero/f30e56351baf05f1a2ec I am getting the following errors: /usr/include/dlang/dmd/std/container.d(1925): Error: templ

Re: How to foreach over a DList?

2014-03-31 Thread H. S. Teoh
On Mon, Mar 31, 2014 at 07:30:11PM +, Jeroen Bollen wrote: > On Monday, 31 March 2014 at 19:26:23 UTC, Jeroen Bollen wrote: > >On Monday, 31 March 2014 at 18:24:39 UTC, H. S. Teoh wrote: > >>On Mon, Mar 31, 2014 at 05:50:16PM +, Jeroen Bollen wrote: > >>>I am trying to foreach over a std.co

Re: tuple (TypeTuple kind) multi-initialization. Actually documented?

2014-03-31 Thread monarch_dodra
On Monday, 31 March 2014 at 21:05:11 UTC, bearophile wrote: monarch_dodra: bearophile made a suggestion that we should deprecate this. https://d.puremagic.com/issues/show_bug.cgi?id=6367 It goes against the idea of tuple. No language that I know (Haskell, Rust, F#, Python, and more) that has

Re: tuple (TypeTuple kind) multi-initialization. Actually documented?

2014-03-31 Thread bearophile
No language that I know (Haskell, Rust, F#, Python, and more) that has tuples supports the initialization of a n-tuple with a scalar value. In Python there is a way to build a n-tuple from a 1-tuple, but the seed is not a scalar, and this is an explicit syntax: (5,) * 3 (5, 5, 5) Bye, bea

Re: tuple (TypeTuple kind) multi-initialization. Actually documented?

2014-03-31 Thread bearophile
monarch_dodra: bearophile made a suggestion that we should deprecate this. https://d.puremagic.com/issues/show_bug.cgi?id=6367 It goes against the idea of tuple. No language that I know (Haskell, Rust, F#, Python, and more) that has tuples supports the initialization of a n-tuple with a scal

Re: template interface and delegates

2014-03-31 Thread Steven Schveighoffer
On Mon, 31 Mar 2014 14:58:30 -0400, anonymous wrote: Hi, I'm new to D and played a bit with templates and delegates. Now i discovered some behaviore that i don't understand. Can somebody explain me why i get two different outputs? import std.stdio; interface A(T){ bool GetBool();

tuple (TypeTuple kind) multi-initialization. Actually documented?

2014-03-31 Thread monarch_dodra
If you declare an instance of a tuple, eg TypeTuple!(int, int, int), you can initialize all members from a single argument. EG: TypeTuple!(int, int, int) a = 5; bearophile made a suggestion that we should deprecate this. https://d.puremagic.com/issues/show_bug.cgi?id=6367 I'd like to know if t

Re: Avoiding Range Checks in Slice Expressions

2014-03-31 Thread Nordlöw
If not, what would it require to implement it? That would be an interesting task to fix :) DMD source references anyone?

Re: template interface and delegates

2014-03-31 Thread Justin Whear
On Mon, 31 Mar 2014 18:58:30 +, anonymous wrote: > Hi, > I'm new to D and played a bit with templates and delegates. > Now i discovered some behaviore that i don't understand. Can somebody > explain me why i get two different outputs? > > > import std.stdio; > > > interface A(T){ > b

Re: Avoiding Range Checks in Slice Expressions

2014-03-31 Thread Nordlöw
If they are range-checked, it would be a good addition to the optimizer to remove them. My guess is that it is range-checked. $/n is of course always within range if n is positive integer >= 1. But what about in the general indexing/slicing case? In that case it would be useful if we could

Re: Parsing

2014-03-31 Thread Joel
On Monday, 31 March 2014 at 17:25:58 UTC, Marco Leise wrote: Am Mon, 31 Mar 2014 04:06:38 + schrieb "Joel" : I've got a program that uses user input, but I'm having trouble with it. Here's an example, the unenclosed numbers (1 2 3 in example) add entries: 0 Achievement 1 2 3 c"Won!" st

How to set JSON_TYPE in 2.0.65

2014-03-31 Thread nrgyzer
Hi guys, I updated my dmd version from 2.0.63 to 2.0.65 and having some trouble with my JSON-definitions. The code below worked in 2.0.63 but not in 2.0.65: JSONValue oJson = JSONValue(); oJson.type = JSON_TYPE.OBJECT; // FAILS oJson.object["myEntry"] = JSONValue(); oJson.object["myEntry"].ty

Re: How to foreach over a DList?

2014-03-31 Thread Jeroen Bollen
Still not working: https://gist.github.com/Binero/f30e56351baf05f1a2ec /usr/include/dlang/dmd/std/container.d(1925): Error: template std.container.DList!ubyte.DList.insertBeforeNode cannot deduce function from argument types !()(typeof(null), int), candidates are: /usr/include/dlang/dmd/std/co

Re: How to set JSON_TYPE in 2.0.65

2014-03-31 Thread Justin Whear
On Mon, 31 Mar 2014 15:05:10 -0400, Matt Soucy wrote: > I believe that this was simplified in recent releases, so one only needs > to do the following: > > JSONValue oJson; > oJson.object["myEntry"] = "MyText"; > > (Untested but I believe this is how it's supposed to be now) That's correct, the

Re: Parsing

2014-03-31 Thread Joel
Oops, the 'c"Won!"' shouldn't be there, I forgot to use it. On Monday, 31 March 2014 at 19:23:17 UTC, Joel wrote: On Monday, 31 March 2014 at 17:25:58 UTC, Marco Leise wrote: Am Mon, 31 Mar 2014 04:06:38 + schrieb "Joel" : I've got a program that uses user input, but I'm having trouble wi

template interface and delegates

2014-03-31 Thread anonymous
Hi, I'm new to D and played a bit with templates and delegates. Now i discovered some behaviore that i don't understand. Can somebody explain me why i get two different outputs? import std.stdio; interface A(T){ bool GetBool(); T getT(); } class C:A!(double){ override

Re: How to set JSON_TYPE in 2.0.65

2014-03-31 Thread Matt Soucy
On 03/31/2014 02:59 PM, nrgyzer wrote: > Hi guys, > > I updated my dmd version from 2.0.63 to 2.0.65 and having some trouble > with my JSON-definitions. The code below worked in 2.0.63 but not in > 2.0.65: > > JSONValue oJson = JSONValue(); > oJson.type = JSON_TYPE.OBJECT; // FAILS > oJson.object

Re: How to foreach over a DList?

2014-03-31 Thread Jeroen Bollen
On Monday, 31 March 2014 at 18:24:39 UTC, H. S. Teoh wrote: On Mon, Mar 31, 2014 at 05:50:16PM +, Jeroen Bollen wrote: I am trying to foreach over a std.container.DList but it isn't working. I have tried the following code: [...] Maybe try using opSlice: DList myList; for

Re: How to foreach over a DList?

2014-03-31 Thread Jeroen Bollen
On Monday, 31 March 2014 at 19:26:23 UTC, Jeroen Bollen wrote: On Monday, 31 March 2014 at 18:24:39 UTC, H. S. Teoh wrote: On Mon, Mar 31, 2014 at 05:50:16PM +, Jeroen Bollen wrote: I am trying to foreach over a std.container.DList but it isn't working. I have tried the following code: [.

Re: Getting the current datetime converted into a string for writing to stdout

2014-03-31 Thread Gary Willoughby
On Saturday, 29 March 2014 at 05:01:14 UTC, Gary Miller wrote: I've been reading through and trying various code fragments to pull the system date/time in and format it as a string for display on the console. Here's a good primer on the datetime module: http://dlang.org/intro-to-datetime.html

Re: Getting the current datetime converted into a string for writing to stdout

2014-03-31 Thread Gary Willoughby
On Saturday, 29 March 2014 at 05:01:14 UTC, Gary Miller wrote: I've been reading through and trying various code fragments to pull the system date/time in and format it as a string for display on the console. I only need it down to the second and from my current machine so I don't need to use

Getting the current datetime converted into a string for writing to stdout

2014-03-31 Thread Gary Miller
I've been reading through and trying various code fragments to pull the system date/time in and format it as a string for display on the console. I only need it down to the second and from my current machine so I don't need to use any of the more accurate clocks used for benchmarking right no

Re: How to foreach over a DList?

2014-03-31 Thread H. S. Teoh
On Mon, Mar 31, 2014 at 05:50:16PM +, Jeroen Bollen wrote: > I am trying to foreach over a std.container.DList but it isn't working. I > have tried the following code: [...] Maybe try using opSlice: DList myList; foreach (e; myList[]) { ... } ? T -- Three out of two peopl

How to foreach over a DList?

2014-03-31 Thread Jeroen Bollen
I am trying to foreach over a std.container.DList but it isn't working. I have tried the following code: https://gist.github.com/Binero/f30e56351baf05f1a2ec I am getting the following errors: /usr/include/dlang/dmd/std/container.d(1925): Error: template std.container.DList!ubyte.DList.insertB

Re: best D equivalent to C'stimeval

2014-03-31 Thread Marco Leise
Am Mon, 31 Mar 2014 05:09:22 + schrieb "ed" : > Hi, > > Just wondering what the best replacement for C timeval is in D. > I'm looking at std.datetime.SysTime, but std.datetime is huge so > I'm not sure. > > Thanks, > ed If you just need to time something, TickDuration from core.time is an

Re: Parsing

2014-03-31 Thread Marco Leise
Am Mon, 31 Mar 2014 04:06:38 + schrieb "Joel" : > I've got a program that uses user input, but I'm having trouble > with it. > > Here's an example, the unenclosed numbers (1 2 3 in example) add > entries: > > 0 Achievement > 1 2 3 c"Won!" st"4 5 6" <- user input > > (create 3 entries all

Re: destructor, postblit constructor --- force calling always

2014-03-31 Thread Benjamin Thaut
Am 31.03.2014 08:06, schrieb monarch_dodra: On Monday, 31 March 2014 at 01:03:22 UTC, Carl Sturtivant wrote: What about destructors, are they always called, or is this another optimization if the struct is in it's default .init state? In any case, there should be 1 destructor call for every ob

Re: Getting the current datetime converted into a string for writing to stdout

2014-03-31 Thread Kagamin
On Sunday, 30 March 2014 at 08:25:43 UTC, Andre Artus wrote: Considering the international spread of D users I find it surprising that the date & time formatting functions in phobos are not localizable. Formatting should confined to presentation tier: GUI controls, web page generation and must

Re: Avoiding Range Checks in Slice Expressions

2014-03-31 Thread Steven Schveighoffer
On Sun, 30 Mar 2014 15:40:43 -0400, Nordlöw wrote: Does DMD currently avoid range checks in array slice expressions such as f(x[0..$/2]) f(x[$/2..$]) typically found in divide-and-conquer algorithms such as quicksort? If they are range-checked, it would be a good addition to the optimizer t

Re: Does anyone have an example of use of core.sync.Condition

2014-03-31 Thread Steven Schveighoffer
On Sun, 30 Mar 2014 12:09:35 -0400, Matt wrote: I have little experience in multi-threading programming, and was digging into std.concurrency, but I don't really understand the Condition class as it was used there. Could someone provide a bare-bones use of this class? I would be much oblig

Re: CTFE error, but I have no idea what it means.

2014-03-31 Thread Olav Lindekleiv
Here's the issue: http://d.puremagic.com/issues/show_bug.cgi?id=12498 Please ignore the last example above, and look at the one in Bugzilla. On Monday, 31 March 2014 at 11:08:18 UTC, Olav Lindekleiv wrote: On Monday, 31 March 2014 at 11:02:24 UTC, bearophile wrote: Olav Lindekleiv: I hope

Re: CTFE error, but I have no idea what it means.

2014-03-31 Thread Olav Lindekleiv
On Monday, 31 March 2014 at 11:02:24 UTC, bearophile wrote: Olav Lindekleiv: I hope someone with more D experience can tell me what's going on here, and how to fix it. It's a compiler bug. I suggest to minimize manually the example code as much as possible, and then add it to Bugzilla. Bye

Re: CTFE error, but I have no idea what it means.

2014-03-31 Thread bearophile
Olav Lindekleiv: I hope someone with more D experience can tell me what's going on here, and how to fix it. It's a compiler bug. I suggest to minimize manually the example code as much as possible, and then add it to Bugzilla. Bye, bearophile

CTFE error, but I have no idea what it means.

2014-03-31 Thread Olav Lindekleiv
I've been experimenting with D for a little while now. For the most part, I've been able get help from the language/library reference and IRC. But not this time. So here's the thing: http://dpaste.dzfl.pl/14680a8cec77 I've run it through Dustmite to reduce it to a smaller chunk of code. It ru