Version française
Home     About     Download     Resources     Contact us    
Browse thread
fixed length arrays as types
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Chris Hecker <checker@d...>
Subject: Re: fixed length arrays as types

>To me, having array sizes in the array types is mostly a left-over
>from languages where the compiler needs to treat static or
>stack-allocated arrays differently than dynamically-allocated arrays.
>My feeling is that when all arrays are dynamically allocated, it's
>more natural and a whole lot simpler to never reflect array sizes in
>array types.  

I disagree about this.  It's really about type safety and strong typing.  You can catch a lot of errors if you can type the shape of the array (especially in numerical code).  Not only can you get rid of assert(size(array)==4) in every numerical function, but you can also safely get rid of runtime bounds checks in some cases (as Xi's work shows).  But, ignoring efficiency, I think the added type safety is a win.

>As a case in point, the evolution from C++ to Java
>follows this path.

I think it's clear Java is a step backwards relative to C++ in the realm of typesafety.  I don't mean to start a flame war, however.  I'm no fan of C++ either these days.

Chris