@Araq:

As per my consideration in my last posts:

> unless every object was owned by default...

Although that could work, it likely isn't a good idea as it would put the 
overhead of owned/dangling "hooks" on every data type and it's unnecessary.

Rather, it must be used according to the "simple rule" I mentioned: "Every data 
type that either refers to the heap or contains something referring to the heap 
must be created within an "owned" wrapper so that it can be either "owned" or 
cast to the distinct "dangling" wrapper according to the rules of its copy/move 
semantics.

So the next question is: Given such a simple rule, it seems that the compiler 
will be able to check whether "owned" needs to be applied or not and can guide 
the programmer, then could the compiler insert the "owned" wrapper itself when 
necessary on creation?

If it could, then would the "owned/dangling" keywords not be necessary and "it 
would just work" including the implicit casting to "dangling" according to the 
copy/move rules, although when one could see when things have been wrapped by 
looking at the "repr" of a binding where the "owned/dangling" wrappers would 
show up? One could still override what the compiler would automatically do by 
applying the deepCopy/shallowCopy procs, which for these wrappers are 
complements of each other where deepCopy takes an "owned" or a "dangling" and 
makes a new independent "owned" and shallowCopy takes a "owned" or a "dangling" 
and always casts to output a "dangling".

I see that making this automatic avoids some complication the compiler might 
have in eliding nested "owned" wrappers: Consider a Window that creates an 
"owned" wrapper that contains not only a Button that is "owned but also many 
nested items all of which are owned, perhaps to many levels deep; for 
efficiency it would be good if the compiler elides all those nested "owned" 
wrappers away except for the outer one.

If the compiler needs to elide away all the declared "owned" wrappers, wouldn't 
it be better (simple) that the compiler just injects the outer "owned" wrapper 
by itself as necessary according to the "simple rule"?

Reply via email to