Function, signatures and tuples

Russel Winder russel at russel.org.uk
Fri Nov 12 11:13:33 PST 2010


Is there an easy explanation of why I cannot do:

        real partialSum ( immutable Tuple ! ( long , long , real )
        data )

but instead have to do:

        real partialSum ( T ... ) ( T data )

to be frank I really don't get this latter which is what compiles -- I
have no idea if it works yet there are other problems with my code.
Specifically, how do I create an array of tuples?  TDPL has little on
tuples (p.163 basically) and the online manual has little as well.  I
tried:

        auto inputData = Tuple ! ( long , long , real )
        [ numberOfThreads ] ;

but this errors out with:

        pi_d2_parallelMap.d(26): Error: template instance template 'Tuple' is not defined
        pi_d2_parallelMap.d(26): Error: Tuple!(long,long,real) must be an array or pointer type, not void

what is worse trying to set values in the array:

        foreach ( i ; 0 .. numberOfThreads ) { inputData[i] = tuple ( 1 + i * sliceSize , ( i + 1 ) * sliceSize , delta ) ; }

I get the error:

        pi_d2_parallelMap.d(27): Error: undefined identifier tuple

Please tell me I am being stupid and that I should read some specific
reference of TFM :-)

Thanks.

-- 
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/20101112/ce6ae92f/attachment-0001.pgp>


More information about the Digitalmars-d mailing list