Unique as a transitive type?

Paul D. Anderson paul.d.removethis.anderson at comcast.andthis.net
Mon Jun 1 17:37:18 PDT 2009


In the short time I was at the Kahili coffeehouse summit I heard Walter say more than once that he was troubled by the idea of more transitive construction types because he was afraid of the combinatorial explosion that would occur. 

And that was just adding 'unique'. Bartosz was trying to talk him into 'unique' and 'lent'.

I don't know if Bartosz and Andrei and Walter came to any agreement -- they seemed to be in three mutually exclusive frames of mind at the start anyway.

>From my knothole I think unique and lent would be positive additions, even if it does offend Walter's finer sensibilities!

Paul


Jason House Wrote:

> Andrei has stated previously that unique was left out of the type system because it added little value to the const system. Now that shared and multithreading are here, unique has more value.
> 
> I have two basic questions:
> 
> 1. What would make unique difficult to add?
> 
> 2. What benefits do you forsee?
> 
> 
> Here are my thoughts:
> 1) Escape analysis - construction of unique objects must be careful with how they manipulate their members. This would require scope parameters (AKA lent in Bartosz's blog/literature). After construction, it may also be necessary to update the manipulate the unique object while preserving its uniqueness. Personally, I like the idea of scope by default, but I'm probably in the minority.
> 
> 2) Plugs a gaping hole in the type system. Even with shared added, I had a moderate multi-threaded code base compile and run without use of shared or casting. That boiled down to an inability to start threads without (silently) subverting the type system. 
> It's also possible to optimize operations on unique data in ways that one can't do when a rogue write reference might exist somewhere.  That's not the same as invariant, but it's similar. Unique can be implicitly cast to scope invariant. 




More information about the Digitalmars-d mailing list