Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- T
- -- the actual object
- -- has its own identity
- T[n]
- -- an array of size n
- -- n must be a compile time constant
- ptr T
- -- memory address
- -- ptr is how you break the type system/lifetime analysis
- -- in case you need to do something it does not understand
- -- (actually, any low level stuff)
- -- as ptr is inherently unsafe, it is Discardable, Duplicable and Relocatable
- -- ptr[] T - pointer to an array of T of an unknown length
- ref[lifetime] T
- -- an alias to another identity
- -- tracks its lifetime, does not allow dangling references (unless pointers are involved)
- -- a code using only refs is safe (in the sense that if you have a memory corruption bug,
- -- it is somewhere else)
- -- ref T is always Discardable, Duplicable and Relocatable
- in[lifetime] T
- -- ref who's also identity thief
- -- after 'in'-reference is created to some identity, this identity is no more
- -- if T isn't Discardable, `in T` is not Discardable either
- out[lifetime] T
- -- ref to uninitialized object
- -- 'out T' is not Discardable and not Duplicable, but Relocatable
- -- the only way to "discard" an 'out'-reference, is to assign a value to it
- -- this turns out- reference into a ref- reference of the same lifetime
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement