Owned members

Alex Khmara alex.khmara at gmail.com
Sat Dec 25 14:18:07 PST 2010


On Sat, 25 Dec 2010 19:18:43 -0000, Robert Jacques <sandford at jhu.edu>  
wrote:

> This @owned is very similar to previous 'scope' proposals (and oddly  
> dissimilar to previous owned proposals). To answer your question, under  
> previous proposals the scope keyword would allow you to declare that a  
> variable doesn't escape the current scope. So you could define external  
> functions that would take a 'scope int[]' and be guaranteed that it  
> wouldn't escape. (returning scoped values has to obey certain  
> restrictions)
>
> The previous 'owned' proposals are a bit more general. Owned types allow  
> you parameterize a type on a variable, which sounds complex, but what it  
> means in terms of the runtime, is that all objects in the same ownership  
> group shared the same monitor. The big advantage is that inside a  
> synchronized method you don't have to synchronize other 'owned' objects  
> of the same type. It also makes this like unique a lot more viable,  
> since you can now define trees, etc.

Ok, I'll try to find previous proposals about 'scope' - now I cannot  
understand
how you can prevent external function from, e.g., saving owned object or  
array (i.e. references)
in global variable, if it's at all possible to pass owned variables into  
external functions.


More information about the Digitalmars-d mailing list