Of course it is more readable - it requires less coding and the [] ( or some other syntax for the same thing ) makes it clear that we are operating on C array elements and not just meaningless bytes and byte offsets.
Having to access everything by byte offsets, is a little like the days Of old BASIC where one used Peeks and Pokes for everything. We're past that now and like to access pointer based data according to type. 1) because it removes the need to include offset calculations along with explicit code for datatype sizes. This stuff should be hidden. I would rather write dim myElement As Int64 = myPtr.Int64[ index ] in order to get the "index" th Int64 element in the array ( assuming it exists ) Instead of: myElement As Int64 = myPtr.int64( 8 * index ) Or dim myElement As myStructure = myPtr. myStructure[ index ] Instead of: myElement As myStructure = myPtr. myStructure( myStructure.Size * index ) 2) because the compiler knows all these sizes at build time and thus can optimise these offset calculations internally for speed in certain cases. I am not saying get rid of the existing (index) functionality, but considering pointers to arrays are very common when dealing with Declares etc, it makes sense to make the syntax as terse and elegant as we can. And its hardly rocket science to incorporate this feature in the compiler. On 22/1/07 21:51, "Charles Yeomans" <[EMAIL PROTECTED]> wrote: > > On Jan 22, 2007, at 4:23 PM, Daniel Stenning wrote: > >> http://www.realsoftware.com/feedback/viewreport.php?reportid=forgezvx >> >> When dealing with declares or ptr, currently the only way of >> accessing a C >> array via a PTR variable is by using a byte offset. It would be >> much more >> readable and helpful if one could also access C array elements in a >> manner >> similar to C - >> >> one solution might be to use [index] as opposed to (index) >> >> so we could write: >> >> dim myCInt64ArrayPointer as Ptr = getMyPointer() >> dim myElement as Int64 = Ptr.Int64[8] >> >> note that whereas dim myElement as Int64 = Ptr.Int64(8) returns the >> second >> element as an offset of 8 gives us the second Int64 in the array >> dim myElement as Int64 = Ptr.Int64[8] would return the 8th element >> - ie >> using >> an offset from Ptr of 8X8 bytes. >> Sign on here if this is of use to you: >> >> http://www.realsoftware.com/feedback/viewreport.php?reportid=forgezvx >> >> >> this would apply naturally to pointers to arrays of structs - so we >> could >> write: >> dim myElement as myStruct = Ptr. myStruct[8] would again return the >> 8th >> element. >> >> this saves a lot of tedious offset calculations and makes such code >> potentially faster and readable. > > > Why would it make code potentially faster and readable? I find the > former hard to believe, and certainly disagree with the latter. > > Charles Yeomans > _______________________________________________ > Unsubscribe or switch delivery mode: > <http://www.realsoftware.com/support/listmanager/> > > Search the archives of this list here: > <http://support.realsoftware.com/listarchives/lists.html> > _______________________________________________ Unsubscribe or switch delivery mode: <http://www.realsoftware.com/support/listmanager/> Search the archives of this list here: <http://support.realsoftware.com/listarchives/lists.html>
