When is casting const() away actually necessary? (Used to be: Re: Why D const is annoying)

David Nadlinger see at klickverbot.at
Thu May 3 08:53:56 PDT 2012


On Thursday, 3 May 2012 at 13:40:41 UTC, Steven Schveighoffer 
wrote:
> On Wed, 02 May 2012 12:59:34 -0400, David Nadlinger 
> <see at klickverbot.at> wrote:
>> Additionally, shared is currently little more than a marker 
>> for non-TLS data.
>
> No, it's very important that it is a type constructor.  For 
> example, it makes weak-pure functions possible.
>
> I think there is a large piece of shared missing/undefined, and 
> that is, how do I mark something shared as "temporarily local".
>  I think Bartosz proposed something like "lent".
>
> We essentially need the equivalent of const for shared.  Const 
> unifies immutable and mutable, we need something to unify 
> shared and thread-local.
>
> The problem is, something like this needs to be combined with 
> thread-locks.  I wonder if some kind of ARC would be useful for 
> automatically unlocking the data.

Yes, it is important indeed, at least if we want the type system 
to give guarantees about multi-threaded code. I just meant that 
in the current state, it provides little more than a way to make 
sure that shared data isn't accidentally passed around/used in 
places where synchronization isn't properly handled, because none 
of the fancier related ideas have actually been implemented so 
far.

David


More information about the Digitalmars-d mailing list