Re: a newbie problem regarding splitter()

2017-04-13 Thread alex via Digitalmars-d-learn
On Thursday, 13 April 2017 at 06:42:30 UTC, Ali Çehreli wrote: On 04/12/2017 11:33 PM, alex wrote: > Hello, > "The D Programming Language" by Andrei Alexandrescu. Great book but a lot has changed in D since the book was written in 2010. Your issue is in the book's errata: http://erdani.com/

Re: a newbie problem regarding splitter()

2017-04-12 Thread Ali Çehreli via Digitalmars-d-learn
On 04/12/2017 11:33 PM, alex wrote: > Hello, > > I've just started learning D, working my way through "The D Programming > Language" by Andrei Alexandrescu. Great book but a lot has changed in D since the book was written in 2010. Your issue is in the book's errata: http://erdani.com/tdpl/er

a newbie problem regarding splitter()

2017-04-12 Thread alex via Digitalmars-d-learn
Hello, I've just started learning D, working my way through "The D Programming Language" by Andrei Alexandrescu. On page 8 there is: import std.stdio, std.string; void main(){ uint[string] dictionary; foreach (line; stdin.byLine()){ foreach (word; splitter(strip(line))){

Re: newbie problem with nothrow

2016-11-01 Thread Steven Schveighoffer via Digitalmars-d-learn
On 11/1/16 12:24 PM, Jonathan M Davis via Digitalmars-d-learn wrote: On Tuesday, November 01, 2016 12:19:11 Steven Schveighoffer via Digitalmars- d-learn wrote: On 11/1/16 11:54 AM, Jonathan M Davis via Digitalmars-d-learn wrote: On Tuesday, November 01, 2016 10:57:38 Steven Schveighoffer via

Re: newbie problem with nothrow

2016-11-01 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, November 01, 2016 12:19:11 Steven Schveighoffer via Digitalmars- d-learn wrote: > On 11/1/16 11:54 AM, Jonathan M Davis via Digitalmars-d-learn wrote: > > On Tuesday, November 01, 2016 10:57:38 Steven Schveighoffer via > >> Is there not some assumeNoThrow wrapper somewhere? > > > > Some

Re: newbie problem with nothrow

2016-11-01 Thread Steven Schveighoffer via Digitalmars-d-learn
On 11/1/16 11:54 AM, Jonathan M Davis via Digitalmars-d-learn wrote: On Tuesday, November 01, 2016 10:57:38 Steven Schveighoffer via Digitalmars- d-learn wrote: On 10/31/16 6:29 PM, Jonathan M Davis via Digitalmars-d-learn wrote: assert(0, "format threw when it shouldn't be possible."); T

Re: newbie problem with nothrow

2016-11-01 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, November 01, 2016 10:57:38 Steven Schveighoffer via Digitalmars- d-learn wrote: > On 10/31/16 6:29 PM, Jonathan M Davis via Digitalmars-d-learn wrote: > > On Monday, October 31, 2016 22:20:59 Kapps via Digitalmars-d-learn wrote: > >> Assuming you're sure it'll never throw. To enforce t

Re: newbie problem with nothrow

2016-11-01 Thread Steven Schveighoffer via Digitalmars-d-learn
On 10/31/16 6:29 PM, Jonathan M Davis via Digitalmars-d-learn wrote: On Monday, October 31, 2016 22:20:59 Kapps via Digitalmars-d-learn wrote: Assuming you're sure it'll never throw. To enforce this, use try { } catch { throw new Error("blah"); }. You can still throw errors, just not exceptions

Re: newbie problem with nothrow

2016-11-01 Thread Daniel9 via Digitalmars-d-learn
On Monday, 31 October 2016 at 22:29:19 UTC, Jonathan M Davis wrote: On Monday, October 31, 2016 22:20:59 Kapps via Digitalmars-d-learn wrote: Assuming you're sure it'll never throw. To enforce this, use try { } catch { throw new Error("blah"); }. You can still throw errors, just not exceptions

Re: newbie problem with nothrow

2016-11-01 Thread Mike Parker via Digitalmars-d-learn
On Monday, 31 October 2016 at 22:20:59 UTC, Kapps wrote: Wrap a body of the function to try {} catch {} and it'll work. Assuming you're sure it'll never throw. To enforce this, use try { } catch { throw new Error("blah"); }. You can still throw errors, just not exceptions (as errors are not

Re: newbie problem with nothrow

2016-10-31 Thread Mike Parker via Digitalmars-d-learn
On Monday, 31 October 2016 at 16:55:51 UTC, WhatMeWorry wrote: Is there a way to turn off nothrow or work around it? Because to me it looks like nothrow prevents me from doing anything useful. extern(C) void onKeyEvent(GLFWwindow* window, int key, int scancode, int action, int modifier) not

Re: newbie problem with nothrow

2016-10-31 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, October 31, 2016 22:20:59 Kapps via Digitalmars-d-learn wrote: > Assuming you're sure it'll never throw. To enforce this, use try > { } catch { throw new Error("blah"); }. You can still throw > errors, just not exceptions (as errors are not meant to be > caught). I always use assert(0).

Re: newbie problem with nothrow

2016-10-31 Thread Kapps via Digitalmars-d-learn
On Monday, 31 October 2016 at 17:04:28 UTC, Temtaime wrote: On Monday, 31 October 2016 at 16:55:51 UTC, WhatMeWorry wrote: Is there a way to turn off nothrow or work around it? Because to me it looks like nothrow prevents me from doing anything useful. extern(C) void onKeyEvent(GLFWwindow*

Re: newbie problem with nothrow

2016-10-31 Thread Temtaime via Digitalmars-d-learn
On Monday, 31 October 2016 at 16:55:51 UTC, WhatMeWorry wrote: Is there a way to turn off nothrow or work around it? Because to me it looks like nothrow prevents me from doing anything useful. extern(C) void onKeyEvent(GLFWwindow* window, int key, int scancode, int action, int modifier) not

newbie problem with nothrow

2016-10-31 Thread WhatMeWorry via Digitalmars-d-learn
Is there a way to turn off nothrow or work around it? Because to me it looks like nothrow prevents me from doing anything useful. extern(C) void onKeyEvent(GLFWwindow* window, int key, int scancode, int action, int modifier) nothrow { if(queue.roomInQueue()) { auto event = ne

Re: Newbie problem

2013-06-20 Thread Roger Stokes
Adam, many thanks for your helpful reply. On Wednesday, 19 June 2013 at 19:53:08 UTC, Adam D. Ruppe wrote: On Wednesday, 19 June 2013 at 19:14:58 UTC, Roger Stokes wrote: and got this compiler diagnostic: Oh, I thought you were writing to a socket. Yeah, to a different thread, D will complai

Re: Newbie problem

2013-06-20 Thread Roger Stokes
Many thanks, Ali I put together your suggestions, and it all works correctly ! Thanks again. On Wednesday, 19 June 2013 at 19:50:55 UTC, Ali Çehreli wrote: On 06/19/2013 12:14 PM, Roger Stokes wrote: > and the result compiled and executed with no error signals, but the > resulting output of t

Re: Newbie problem

2013-06-19 Thread Adam D. Ruppe
On Wednesday, 19 June 2013 at 19:14:58 UTC, Roger Stokes wrote: and got this compiler diagnostic: Oh, I thought you were writing to a socket. Yeah, to a different thread, D will complain if you don't make a sharable copy. So you do want to idup it... [47, 47, 32, 101, 120, 97,

Re: Newbie problem

2013-06-19 Thread Ali Çehreli
On 06/19/2013 12:14 PM, Roger Stokes wrote: > and the result compiled and executed with no error signals, but the > resulting output of the file-copy was not the same as the input, it > looked like this: > > std.concurrency.OwnerTerminated@std\concurrency.d(248): Owner terminated For a clean exi

Re: Newbie problem

2013-06-19 Thread Roger Stokes
Many thanks for swift response. I'm still in difficulty, alas. There were two possibilities suggested: firstly, Adam D. Ruppe wrote: The problem here is that byChunk returns a mutable buffer, type ubyte[]. If you said "foreach(ubyte[] buffer; stdin.byChunk(bufferSize)) {...}" you should be

Re: Newbie problem

2013-06-19 Thread Adam D. Ruppe
On Wednesday, 19 June 2013 at 15:25:15 UTC, Roger Stokes wrote: page406x.d(11): Error: cannot implicitly convert expression (__r24.front()) of type ubyte[] to immutable(ubyte)[] foreach (immutable(ubyte)[] buffer; stdin.byChunk(bufferSize)) { The problem here is that byChunk returns a mu

Newbie problem

2013-06-19 Thread Roger Stokes
I'd be grateful for advice. The problem is that I can't get the example on page 406-7 of the"The D Programming Language " to compile. I've cut and pasted the text from the website, and corrected the typo (undefined tgt, so use stdout instead). I get this diagnostic: page406x.d(11): Error: ca