Question about std.bind

Russel Winder russel at russel.org.uk
Sat Nov 13 00:12:35 PST 2010


On Fri, 2010-11-12 at 23:14 +0300, Dmitry Olshansky wrote:
[ . . . ]
> > 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...
[ . . . ]

I will certainly give using an anonymous function in this way a go, but
if partial application is a part of the language (and I am using D
2.050), then it ought to work. 

Sadly, using an anonymous function my code compiles, but on execution
just gives a segmentation fault.


[Thread debugging using libthread_db enabled]
[New Thread 0xf7d1fb70 (LWP 13922)]

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0xf7d1fb70 (LWP 13922)]
0x0804ee0a in _d_monitorenter ()



-- 
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 russel.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/attachments/20101113/ed4aaadd/attachment.pgp>


More information about the Digitalmars-d mailing list