Immutable Structs and std.concurrency
Russel Winder
russel at winder.org.uk
Thu Apr 19 06:27:51 PDT 2012
The program:
import std.concurrency ;
import std.stdio ;
/*immutable*/ struct X { int i ; }
void printI ( ) {
receive (
( X x ) { writeln ( x.i ) ; }
) ;
}
int main ( immutable string[] args ) {
auto x = spawn ( & printI ) ;
x.send ( X ( 3 ) ) ;
return 0 ;
}
behaves entirely as expected. Taking the comments off the immutable
leads to:
core.exception.AssertError@/home/users/russel/lib.Linux.x86_64/DMD2/bin64/../../src/phobos/std/variant.d(286): X
----------------
/tmp/.rdmd-1000/home/users/russel/Progs/OddsByLanguage/D/Odds/immutableStruct.d.EDDA68DBDAF917356C855298813D6CD2(_d_assert_msg+0x1f) [0x43f81f]
/tmp/.rdmd-1000/home/users/russel/Progs/OddsByLanguage/D/Odds/immutableStruct.d.EDDA68DBDAF917356C855298813D6CD2(long std.variant.VariantN!(32uL).VariantN.handler!(immutableStruct.X).handler(std.variant.VariantN!(32uL).VariantN.OpID, ubyte[32]*, void*).bool tryPutting(immutableStruct.X*, TypeInfo, void*)+0x7a) [0x43b0fa]
/tmp/.rdmd-1000/home/users/russel/Progs/OddsByLanguage/D/Odds/immutableStruct.d.EDDA68DBDAF917356C855298813D6CD2(long std.variant.VariantN!(32uL).VariantN.handler!(immutableStruct.X).handler(std.variant.VariantN!(32uL).VariantN.OpID, ubyte[32]*, void*)+0x103) [0x43ae03]
/tmp/.rdmd-1000/home/users/russel/Progs/OddsByLanguage/D/Odds/immutableStruct.d.EDDA68DBDAF917356C855298813D6CD2(@property immutableStruct.X std.variant.VariantN!(32uL).VariantN.get!(immutableStruct.X).get()+0x57) [0x434cf7]
/tmp/.rdmd-1000/home/users/russel/Progs/OddsByLanguage/D/Odds/immutableStruct.d.EDDA68DBDAF917356C855298813D6CD2(void std.concurrency.Message.map!(void function(immutableStruct.X)*).map(void function(immutableStruct.X)*)+0x46) [0x434c96]
/tmp/.rdmd-1000/home/users/russel/Progs/OddsByLanguage/D/Odds/immutableStruct.d.EDDA68DBDAF917356C855298813D6CD2(bool std.concurrency.MessageBox.get!(void function(immutableStruct.X)*).get(scope void function(immutableStruct.X)*).bool onStandardMsg(ref std.concurrency.Message)+0x2d) [0x434731]
/tmp/.rdmd-1000/home/users/russel/Progs/OddsByLanguage/D/Odds/immutableStruct.d.EDDA68DBDAF917356C855298813D6CD2(bool std.concurrency.MessageBox.get!(void function(immutableStruct.X)*).get(scope void function(immutableStruct.X)*).bool scan(ref std.concurrency.List!(std.concurrency.Message).List)+0xd3) [0x434a47]
/tmp/.rdmd-1000/home/users/russel/Progs/OddsByLanguage/D/Odds/immutableStruct.d.EDDA68DBDAF917356C855298813D6CD2(bool std.concurrency.MessageBox.get!(void function(immutableStruct.X)*).get(scope void function(immutableStruct.X)*)+0x15e) [0x434692]
/tmp/.rdmd-1000/home/users/russel/Progs/OddsByLanguage/D/Odds/immutableStruct.d.EDDA68DBDAF917356C855298813D6CD2(void std.concurrency.receive!(void function(immutableStruct.X)*).receive(void function(immutableStruct.X)*)+0x2e) [0x434526]
/tmp/.rdmd-1000/home/users/russel/Progs/OddsByLanguage/D/Odds/immutableStruct.d.EDDA68DBDAF917356C855298813D6CD2(void immutableStruct.printI()+0x13) [0x433d1b]
/tmp/.rdmd-1000/home/users/russel/Progs/OddsByLanguage/D/Odds/immutableStruct.d.EDDA68DBDAF917356C855298813D6CD2(_D3std11concurrency11__T6_spawnZ6_spawnFbPFZvZS3std11concurrency3Tid4execMFZv+0x3d) [0x43abb5]
/tmp/.rdmd-1000/home/users/russel/Progs/OddsByLanguage/D/Odds/immutableStruct.d.EDDA68DBDAF917356C855298813D6CD2(void core.thread.Thread.run()+0x2a) [0x449caa]
/tmp/.rdmd-1000/home/users/russel/Progs/OddsByLanguage/D/Odds/immutableStruct.d.EDDA68DBDAF917356C855298813D6CD2(thread_entryPoint+0xf3) [0x449a43]
----------------
I believe this is wrong on so many levels, but is it because I don't
know D?
--
Russel.
=============================================================================
Dr Russel Winder t: +44 20 7585 2200 voip: sip:russel.winder at ekiga.net
41 Buckmaster Road m: +44 7770 465 077 xmpp: russel at winder.org.uk
London SW11 1EN, UK w: www.russel.org.uk skype: russel_winder
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-learn/attachments/20120419/ab39b511/attachment.pgp>
More information about the Digitalmars-d-learn
mailing list