On 10/10/2013 12:51 AM, Jacob Carlborg wrote:
On 2013-10-10 09:18, Walter Bright wrote:
1. Shared data cannot be passed to regular functions.
That I understand.
2. Functions that create data structures would have to know in advance
that they'll be creating a shared object. I'm not so sure this would not
be an invasive change.
If the function doesn't know it creates shared data it will assume it's not and
it won't use any synchronization. Then suddenly someone casts it to "shared" and
you're in trouble.
Same comment as for immutable data - create the data structure as thread local,
because of (1), and then cast to shared and hand it to another thread.
3. Immutable data is implicitly shared. But it is not created immutable
- it is created as mutable data, then set to some state, then cast to
immutable.
It should be possible to create immutable data in the first place. No cast
should be required.