I have a code fragment:

  auto threads = new Thread[numberOfThreads] ;  
  foreach ( i ; 0 .. numberOfThreads ) {
    void delegate ( ) closedPartialSum ( ) {
      immutable id = i ;
      return ( ) { partialSum ( id , sliceSize , delta ) ; } ;
    }
    threads[i] = new Thread ( closedPartialSum ) ;
  }

which clearly should be doable using map from std.algorithm.  So I
tried:

  auto threads = map ! ( function Thread ( int i ) {
      void delegate ( ) closedPartialSum ( ) {
        immutable id = i ;
        return ( ) { partialSum ( id , sliceSize , delta ) ; } ;
      }
      return new Thread ( closedPartialSum ) ;
    } ) ( 0 .. numberOfThreads )

which fails:

pi_d2_threadsGlobalState.d(41): found '..' when expecting ','
pi_d2_threadsGlobalState.d(57): semicolon expected following auto
declaration, not 'foreach'

So clearly 0 .. numberOfThreads only means a range of integers in a
foreach or array index only and not everywhere as it does in all
sensible languages :-((

I am clearly missing something, anyone any ideas?

Thanks.


-- 
Russel.
=============================================================================
Dr Russel Winder      t: +44 20 7585 2200   voip: sip:[email protected]
41 Buckmaster Road    m: +44 7770 465 077   xmpp: [email protected]
London SW11 1EN, UK   w: www.russel.org.uk  skype: russel_winder

Attachment: signature.asc
Description: This is a digitally signed message part

Reply via email to