static arrays.

Dave Dave_member at pathlink.com
Mon Jan 29 20:37:18 PST 2007


Static ("rectangular") multi-dim arrays can perform pretty well - until you start passing them 
around as function parameters.

Two ways to get around that would be to wrap the arrays with a UDT passed byref, or use ptr params, 
with ptr's being much more intuitive for most applications of static arrays (IMO).

Attached is a matrix multiplication program ported to D from the original Shootout Delphi version (*).

The Delphi program has much cleaner syntax. For example, D pointer param dereferencing would be 
(*m1)[a][b] = (*m2)[c][d] * (*m3)[e][f] .

For me this begs the question: Why aren't D static arrays passed byref (**)?

(*) http://dada.perl.it/shootout/matrix_allsrc.html
(**) static array params cannot be 'inout'.

Thanks,

- Dave
-------------- next part --------------
A non-text attachment was scrubbed...
Name: matrix.d
Type: text/x-dsrc
Size: 851 bytes
Desc: not available
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20070129/4e6d91d5/attachment.d>


More information about the Digitalmars-d mailing list