[racket] using s16vector-set! on malloc'ed values

From: John Clements (clements at brinckerhoff.org)
Date: Fri Oct 25 17:49:35 EDT 2013

On Oct 25, 2013, at 2:47 PM, Matthew Flatt wrote:

> At Fri, 25 Oct 2013 15:42:03 -0600, Matthew Flatt wrote:
>> At Fri, 25 Oct 2013 14:28:13 -0700, John Clements wrote:
>>> If I understand correctly, this is because this is taking the "pointer 
>>> value"--probably an 8-byte or 16-byte structure that holds a pointer--and 
>>> treats it like it's a massive s16vector.
>> 
>> Not quite. Both a plain pointer and an `s16vector` value are
>> represented as a wrapper that points to the actual array, but the
>> pointer is in a slightly different place inside each kind of wrapper.
> 
> FWIW, after thinking about it more, my explanation isn't quite right.
> 
> It's more the other way around: an `s16vector` is represented as a
> struct that holds a cpointer, which is a record that points to the
> actual array. So, you had 1 level of indirection where 2 were expected
> (instead of 1 level where 0 were expected).

Ah... there's *always* at least 1 layer of indirection.  This addresses my underlying confusions: I had assumed that casting from a void * to a s16vector would be impossible, becuase of the space required for the tag. If there's always a layer of indirection, though, this works fine.

Thanks again,

John



Posted on the users mailing list.