Skip to content

Instantly share code, notes, and snippets.

@CodeSandwich
Created March 26, 2018 12:38
Show Gist options
  • Save CodeSandwich/333085efb73e8775ddd6633029d6a49b to your computer and use it in GitHub Desktop.
Save CodeSandwich/333085efb73e8775ddd6633029d6a49b to your computer and use it in GitHub Desktop.
main {
A = allocate() // A's lifetime begins
do_stuff(A) // use A
B = A // B's lifetime begins
do_stuff(B) // use B
release(A) // release, A's and B's lifetimes end
do_stuff(A) // <RUN TIME FAIL> use A after its lifetime ended
do_stuff(B) // <RUN TIME FAIL> use B after its lifetime ended
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment