Blocks: implementation details

Looking at the implementation of blocks in gcc, it seems that while
the block struct is documented like
struct block_1 {
struct invok_impl impl;
void *CopyFuncPtr; // only if BLOCK_HAS_COPY_DISPOSE is set
void *DestroyFuncPtr; // only if BLOCK_HAS_COPY_DISPOSE is set
int x; // ref variable list ...
int *y; // byref variable list
(that's roughly consistent with how the test is built, with the first
bytes of the block being an isa pointer), but the actual code defines
it as
struct block_1 {
struct invok_impl *impl;
(i.e. the first bytes of the block point to something with an isa
pointer; not nearly as useful)

Is there a reason for this? It doesn't seem to be just an oversight;
but of course defining blocks that way would take away a lot of the
neatness of the whole implementation.
Being able to store raw blocks in objc data structures would be so
much cooler than having to define a wrapper class.

Just curious, and thanks for implementing this!

Johannes Fortmann

Blocks do end up having an "isa", but the only messages you can really send to them are retain/release. This does allow you to add them to collections etc without a wrapper.