As Marvin used to say - "Life... Don't talk to me about life..."

On 14/9/06 23:13, "Charles Yeomans" <[EMAIL PROTECTED]> wrote:

> Too bad the proposed syntax changes don't prevent the
> OutOfBoundsException :)
> 
> Charles Yeomans
> 
> On Sep 14, 2006, at 5:33 PM, Daniel Stenning wrote:
> 
>>  Currently to use pointers for speed we would do something like :
>> ( or use malloc() )
>> 
>>   dim m as new MemoryBlock(800)
>>   dim p as ptr = m.Ptr(0)
>>   dim kDouble as integer = 4
>>   for i as integer = 0 to 100
>>     p.Double(i*kDouble) = 666.666
>>   Next
>> 
>> ?
>> 
>> - now wouldn't it be nice if we could just do:
>> 
>> dim m as new MemoryBlock(800)
>>   for i as integer = 0 to 100
>>     m.Double[I] = 666.666
>>   Next
>> 
>> Asn well as
>> 
>>   for i as integer = 0 to 100
>>     p.Double[I] = 666.666
>>   Next
>> 
>> On 14/9/06 20:49, "Frank Condello" <[EMAIL PROTECTED]> wrote:
>> 
>>> When you need speed instead of pretty code just access the pointer
>>> directly and calculate the offsets - I'll often define a  stride
>>> constant in the memoryblock subclass to keep things manageable. With
>>> this in mind, pretty code for an array of single-precision floats
>>> might look like this:
>>> 
>>> m.Float(3) = 1.0 // 1 virtual function call
>>> 
>>> When you need speed it looks more like:
>>> 
>>> m.Pointer( m.kStride * 3 ) = 1.0 // No function calls!
>>> 
>>> Not pretty, but it's much faster (though sadly still not as fast as C
>>> code) and if you decide you need doubles later on just change the
>>> stride and everything will continue to work. You can also pass
>>> m.Pointer to declares to save a conversion during those calls.
>>> 
>>> I agree it would be nice to be able to define a byte stride (and even
>>> interleaved strides) for MemoryBlock and Ptr to avoid these extra
>>> steps but it would have to be implemented at the preprocessor or
>>> compiler level to be any good. I'd be happy with a more robust Ptr
>>> type - e.g. instead of "Dim p As Ptr" use something like "Pointer p
>>> As Integer" or "Pointer p As myStruct" where p's offsets match it's
>>> type.
>>> 
>>> Frank.
>>> <http://developer.chaoticbox.com/>
>>> 
>>> 
>>> _______________________________________________
>>> 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>
> 
> _______________________________________________
> 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>

Reply via email to