On 12.11.2010 22:05, Russel Winder wrote:
I have a function with signature:
void partialSum ( immutable long start , immutable long end ,
immutable real delta )
(it turns out the immutable is not a factor here I tried without it and
with const.)
I have a thread creation loop:
foreach ( i ; 0 .. numberOfThreads ) { threads[i] = new Thread ( bind
(& partialSum , 1 + i * sliceSize , ( i + 1 ) * sliceSize , delta ) ) ; }
I'd try to replace bind with delegate:
threads[i] = new Thread( (){ return partialSum(1 + i * sliceSize, (i +
1) * sliceSize, delta); } );
I'm not sure if std.bind works now, and why we even need it in D2 since
it's functionality is completely superseded by delegates.
Well if Q was about D1...
but this does not work. I get the error message as below. I really
haven't a clue what I am doing wrong, but I bet it is something
trivially simple.
dmd -I. -O -release -inline -c -ofpi_d2_threads.o pi_d2_threads.d
/home/users/russel/lib.Linux.x86_64/DMD2/bin/../../src/phobos/std/traits.d(185):
Error: static assert "argument has no parameters"
/home/users/russel/lib.Linux.x86_64/DMD2/bin/../../src/phobos/std/bind.d(977):
instantiated from here: ParameterTypeTuple!(const(EmptySlot)*)
/home/users/russel/lib.Linux.x86_64/DMD2/bin/../../src/phobos/std/bind.d(1003):
instantiated from here: FuncReferenceParamsAsPointers_impl!(NullAlias)
/home/users/russel/lib.Linux.x86_64/DMD2/bin/../../src/phobos/std/bind.d(338):
instantiated from here: FuncReferenceParamsAsPointers!(NullAlias)
/home/users/russel/lib.Linux.x86_64/DMD2/bin/../../src/phobos/std/bind.d(660):
instantiated from here: BoundFunc!(void function(immutable
immutable(long) start, immutable immutable(long) end, immutable immutable(real)
delta),NullAlias,Tuple!(long,long,immutable(double)))
pi_d2_threads.d(31): instantiated from here: bind!(void
function(immutable immutable(long) start, immutable immutable(long) end,
immutable immutable(real) delta),long,long,immutable(double))
--
Dmitry Olshansky