Pointer math

It seems I can do pointer math in Xojo, like this:

dim mb as new MemoryBlock( 9 )
mb.Byte( 0 ) = 31

dim p as Ptr = mb
p = p + Ptr( 1 )
dim u as UInt64 = p.UInt64( 0 )
// u will be 0

Any reason I shouldn’t do this?

[quote=62867:@Kem Tekinay]It seems I can do pointer math in Xojo, like this:

dim mb as new MemoryBlock( 9 )
mb.Byte( 0 ) = 31

dim p as Ptr = mb
p = p + Ptr( 1 )
dim u as UInt64 = p.UInt64( 0 )
// u will be 0

Any reason I shouldn’t do this?[/quote]

Just the typical advice with pointers: be careful not to shoot your foot off.

Cool.

That’s what your foot will be in a few hours…

I think you misspelled that

Its spelled MISSING :stuck_out_tongue:

However, after testing, I find no significant time difference between incrementing the Ptr vs. incrementing an integer index for the Ptr, so I can’t see a practical use for this.