June 17, 2020 Re: what exactly does cast(shared) and cast away shared do? | ||||
---|---|---|---|---|
| ||||
Posted in reply to mw | On Tuesday, 16 June 2020 at 07:22:59 UTC, mw wrote:
> `shared` or not is purely a compile-time attribute, not some runtime dynamic attribute on the object, i.e. at runtime when you get hold of an object on the heap, there's no way you can tell from the object itself whether it's shared or not.
The way to tell it is if the object is typed as shared, then it's shared, if it's not typed as shared, then it's not shared. The only way to circumvent this is to use a cast, that circumvents entire type system.
|
June 17, 2020 Re: what exactly does cast(shared) and cast away shared do? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Simen Kjærås | On Tuesday, 16 June 2020 at 08:07:41 UTC, Simen Kjærås wrote:
> Correct. So it's perfectly possible to have a shared and a non-shared reference to the same object, which is potentially dangerous. A DIP* has been accepted that will limit your ability to do dangerous things in this case, but it is not yet implemented.
>
>
> * https://github.com/dlang/DIPs/blob/master/DIPs/accepted/DIP1024.md
Uh, people already believe DIP1024 is an all purpose safety feature. Hello, it isn't. Especially it does nothing in case you have differently typed references to the same data.
|
Copyright © 1999-2021 by the D Language Foundation