Task

Show how to explicitly allocate and deallocate blocks of memory in your language.

Show access to different types of memory (i.e., heap, stack, shared, foreign) if applicable.




import native
 
// allocate 26 bytes
ptr = native.allocate(26)
 
// store the uppercase alphabet
for i in range(0, 25)
    native.poke(ptr + i, ord("A") + i)
end
 
// output the allocated memory
for i in range(0, 25)
    print chr(native.peek(ptr + i))
end
 
// free the allocated memory
native.free(ptr)