Profiles and restricting references and pointers to certain types
Kubiyak opened this issue · 0 comments
Will profiles permit me to create a type on which it will be illegal to obtain a reference or pointer on? One way to ensure referential integrity is to prevent the taking of references and pointers to begin with.
This is useful for creating API handles, wrapper types, context managers, etc.
Such a type of course cannot exist easily on the heap. It would have to exist on the stack, as a global or possibly as a thread local object. It won't be possible to construct an array of such an object either.
All of this is fine b/c the intended use does not require heap based allocation. These objects move around stack frames threads etc. via copy constructor or assignment operator. Yes, the copy constructor should be allowed to accept an object of the same type via reference and the assignment operator should be allowed the same privilege. I hope that profiles make it possible to express such restrictions.
Unfortunately, shared pointers don't quite suit the use today because the language permits the taking of pointers and references to these which can lead to breaks in any intended referential integrity via shared pointer.