You also need to use volatile if you expect writes to variables to persist when calling longjmp(), because any value the compiler decides to stash in a register will be overwritten. Since Swift lacks volatile, you won't be able to make that work properly. It's fun to play with though.
Having done Java programming I have not been able to write code where I can directly allocate memory in the heap and iterate over it like in C. Correct me if I am wrong with an example.
Good article but trying to write code like in the examples seems very cumbersome compared to writing it in Swift. The Java language syntax is partly to blame.
> where I can directly allocate memory in the heap
Doesn't the "new" keyword always heap-allocate? I guess modulo optimizations like "this is a value-class that won't escape the scope of the method: "in-line" it" (if that is a technique that is in use/possible). Also, it seems reasonable that an array of primitive values would actually be represented as a contiguous piece of memory in the heap.
I guess using setjmp/longjmp to implement something like try-catch in C is something everyone does when they discover this the first time. I did. But I was aware that it isn't a good idea, I just wanted to try it. It was some time between 13 and 11 years ago. I guess other computer science students did the same since the 80ies?
http://vimeo.com/107707576