digitalmars.D.learn - Threading errors.
- dcoder (37/37) Jul 26 2010 Hello.
- Dmitry Olshansky (6/16) Jul 26 2010 I suggest updating compiler - it's should be 2.047 now. The outdated
- Rory Mcguire (4/25) Jul 26 2010 Doesn't work for 2.047 either.
- dcoder (7/21) Jul 26 2010 Yep, I get that same error after upgrading my compiler.
- Philippe Sigaud (15/17) Jul 26 2010 std.typecons.Tuple fields cannot be indexed like arrays, Andrei made a
- Rory Mcguire (2/28) Jul 27 2010 Interesting, I didn't have to comment out return; using dmd 2.047 on lin...
- Philippe Sigaud (5/8) Jul 27 2010 I think I have -w (warnings treated as errors?) always checked. That's m...
- Rory Mcguire (2/20) Jul 27 2010 :) thanks Philippe
- dcoder (6/22) Jul 27 2010 Actually, after making the changes that you suggest, Philippe my program...
- Sean Kelly (1/1) Jul 27 2010 The next release, 2.048, should bring things in line with TDPL. I had m...
- Philippe Sigaud (3/6) Jul 27 2010 Do you mean, indexing tuples directly by a CT value as in msg[1]? Becaus...
- Andrej Mitrovic (4/18) Sep 03 2010 So what's the word on this? Will we have simple indexing of tuples via T...
Hello. I am working through Alexandrescu's "The D Programming Language". He has an example in his concurrency chapter which I can't compile. It looks to be missing a few import packages, but getting over that, I still can't get the example to work: import std.concurrency, std.stdio; import std.contracts, std.typecons; /* I added this */ void main() { auto low = 0, high = 25; auto tid = spawn(&writer); foreach( i; low .. high) { writeln("Main thread: ", i); tid.send(thisTid, i); enforce( receiveOnly!Tid() == tid); } return; } void writer() { for( ;; ) { auto msg = receiveOnly!(Tid, int)(); writeln( "Secondary thread: ", msg[1]); msg[0].send(thisTid); } return; } I get the following compiler error: $ dmd Thread2.d Thread2.d(10): Error: template std.typecons.Tuple!(Tid).Tuple.opEquals(T) if (is(typeof(T.field))) does not match any function template declaration Thread2.d(10): Error: template std.typecons.Tuple!(Tid).Tuple.opEquals(T) if (is(typeof(T.field))) cannot deduce template function from argument types !()(Tid) $ dmd --help Digital Mars D Compiler v2.042 Copyright (c) 1999-2010 by Digital Mars written by Walter Bright Documentation: http://www.digitalmars.com/d/2.0/index.html So, what am I doing wrong here? thanks.
Jul 26 2010
On 26.07.2010 19:45, dcoder wrote:Hello.[snip]$ dmd --help Digital Mars D Compiler v2.042 Copyright (c) 1999-2010 by Digital Mars written by Walter Bright Documentation: http://www.digitalmars.com/d/2.0/index.htmlI suggest updating compiler - it's should be 2.047 now. The outdated distribution could also feature some bugs in std.concurency.So, what am I doing wrong here? thanks.-- Dmitry Olshansky
Jul 26 2010
Dmitry Olshansky wrote:On 26.07.2010 19:45, dcoder wrote:Doesn't work for 2.047 either. dthreadpass.d(19): Error: no [] operator overload for type Tuple!(Tid,int) dthreadpass.d(20): Error: no [] operator overload for type Tuple!(Tid,int)Hello.[snip]$ dmd --help Digital Mars D Compiler v2.042 Copyright (c) 1999-2010 by Digital Mars written by Walter Bright Documentation: http://www.digitalmars.com/d/2.0/index.htmlI suggest updating compiler - it's should be 2.047 now. The outdated distribution could also feature some bugs in std.concurency.So, what am I doing wrong here? thanks.
Jul 26 2010
== Quote from Rory Mcguire (rjmcguire gm_no_ail.com)'s articleDmitry Olshansky wrote:Yep, I get that same error after upgrading my compiler. $ dmd --help Digital Mars D Compiler v2.047 Copyright (c) 1999-2010 by Digital Mars written by Walter Bright Documentation: http://www.digitalmars.com/d/2.0/index.html thanks.On 26.07.2010 19:45, dcoder wrote:Doesn't work for 2.047 either. dthreadpass.d(19): Error: no [] operator overload for type Tuple!(Tid,int) dthreadpass.d(20): Error: no [] operator overload for type Tuple!(Tid,int)$ dmd --help Digital Mars D Compiler v2.042 Copyright (c) 1999-2010 by Digital Mars written by Walter Bright Documentation: http://www.digitalmars.com/d/2.0/index.htmlI suggest updating compiler - it's should be 2.047 now. The outdated distribution could also feature some bugs in std.concurency.
Jul 26 2010
On Mon, Jul 26, 2010 at 19:11, dcoder <dcoder devnull.dev> wrote:== Quote from Rory Mcguire (rjmcguire gm_no_ail.com)'s articlestd.typecons.Tuple fields cannot be indexed like arrays, Andrei made a mistake. To access field #n, use ._n or .field[n]. There is no difference between the two. void writer() { for( ;; ) { auto msg = receiveOnly!(Tid, int)(); // msg is a Tuple!(Tid, int), msg._0 is a Tid, msg._1 is an int. writeln( "Secondary thread: ", msg._1); msg._0.send(thisTid); } } Also, in my case, the return; in writer must be commented out, or DMD complains it cannot be reached. PhilippeDmitry Olshansky wrote:
Jul 26 2010
Philippe Sigaud wrote:On Mon, Jul 26, 2010 at 19:11, dcoder <dcoder devnull.dev> wrote:Interesting, I didn't have to comment out return; using dmd 2.047 on linux== Quote from Rory Mcguire (rjmcguire gm_no_ail.com)'s articlestd.typecons.Tuple fields cannot be indexed like arrays, Andrei made a mistake. To access field #n, use ._n or .field[n]. There is no difference between the two. void writer() { for( ;; ) { auto msg = receiveOnly!(Tid, int)(); // msg is a Tuple!(Tid, int), msg._0 is a Tid, msg._1 is an int. writeln( "Secondary thread: ", msg._1); msg._0.send(thisTid); } } Also, in my case, the return; in writer must be commented out, or DMD complains it cannot be reached. PhilippeDmitry Olshansky wrote:
Jul 27 2010
On Tue, Jul 27, 2010 at 11:25, Rory Mcguire <rjmcguire gm_no_ail.com> wrote:Also, in my case, the return; in writer must be commented out, or DMD complains it cannot be reached.Interesting, I didn't have to comment out return; using dmd 2.047 on linuxI think I have -w (warnings treated as errors?) always checked. That's my Code::Blocks default configuration for DMD. I was on Windows for this test. I never cheked if there was any difference between OSes for this :-)
Jul 27 2010
Philippe Sigaud wrote:On Tue, Jul 27, 2010 at 11:25, Rory Mcguire <rjmcguire gm_no_ail.com> wrote::) thanks PhilippeAlso, in my case, the return; in writer must be commented out, or DMD complains it cannot be reached.Interesting, I didn't have to comment out return; using dmd 2.047 on linuxI think I have -w (warnings treated as errors?) always checked. That's my Code::Blocks default configuration for DMD. I was on Windows for this test. I never cheked if there was any difference between OSes for this :-)
Jul 27 2010
== Quote from Rory Mcguire (rjmcguire gm_no_ail.com)'s articlePhilippe Sigaud wrote:Actually, after making the changes that you suggest, Philippe my program works. Thanks. However, I did not have to comment out the return statement. But when I did compile using the -w flag, I do get the compiler error that you describe. Anyways, thanks for the coding suggestion.:) thanks PhilippeAlso, in my case, the return; in writer must be commented out, or DMD complains it cannot be reached.Interesting, I didn't have to comment out return; using dmd 2.047 on linuxI think I have -w (warnings treated as errors?) always checked. That's my Code::Blocks default configuration for DMD. I was on Windows for this test. I never cheked if there was any difference between OSes for this :-)
Jul 27 2010
The next release, 2.048, should bring things in line with TDPL. I had meant to do this for 2.047, but was too busy with other work to finish in time.
Jul 27 2010
On Tue, Jul 27, 2010 at 19:03, Sean Kelly <sean invisibleduck.org> wrote:The next release, 2.048, should bring things in line with TDPL. I had meant to do this for 2.047, but was too busy with other work to finish in time.Do you mean, indexing tuples directly by a CT value as in msg[1]? Because that was the only error here, I think.
Jul 27 2010
So what's the word on this? Will we have simple indexing of tuples via T[] or do we still need T.field[] and T._1 ? The situations is the same in 2.048 as it was in 2.047. There are more examples of tuples being used via T[] in some Phobos code examples (which don't compile and I've reported that). Otherwise if it stays the way it is I'll send Andrei a message to add the corrections to the errata. Philippe Sigaud Wrote:On Tue, Jul 27, 2010 at 19:03, Sean Kelly <sean invisibleduck.org> wrote:The next release, 2.048, should bring things in line with TDPL. I had meant to do this for 2.047, but was too busy with other work to finish in time.Do you mean, indexing tuples directly by a CT value as in msg[1]? Because that was the only error here, I think. <div class="gmail_quote">On Tue, Jul 27, 2010 at 19:03, Sean Kelly <span dir="ltr"><<a href="mailto:sean invisibleduck.org">sean invisibleduc .org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"> The next release, 2.048, should bring things in line with TDPL. I had meant to do this for 2.047, but was too busy with other work to finish in time.<br> </blockquote></div><br><div>Do you mean, indexing tuples directly by a CT value as in msg[1]? Because that was the only error here, I think.</div><div><br></div>
Sep 03 2010