I asked other programmers, and they said that caret ^
means xor. But it seems there is an obscure use of caret that I don't fully understand. It seems that ^
suffixing a type modifies it in some way, like how suffixing a type with *
declares it a pointer type. The code below works, but can someone explain why and what is going on, and how the caret symbol allows me to declare anonymous function literals inline? I didn't know that you could do that, but I want to fully understand this mysterious functionality.
void(^Function)(void);
int main(int argc, char *argv[]) {
Function = ^{
int x = 10;
printf("%d\n", x);
};
Function();
Function = ^{
putchar(65);
};
Function();
return 0;
}
Also, is this some compiler extension or is this pure C?
This is an Apple extension to C called Blocks, for Grand Central Dispatch.