digitalmars.D.learn - Why no mutable shared from uniqueness?
- Quirin Schroll (13/13) Feb 11 If a pure factory function returns an non-`shared`-type object,
- Timon Gehr (7/21) Feb 15 `const shared` works because it is a supertype of `immutable` and
- Quirin Schroll (2/26) Feb 17 That thread is very interesting. Thanks.
If a pure factory function returns an non-`shared`-type object,
that type should be convertible to `shared` or am I mistaken?
Essentially, this should compile:
```d
int[] make() pure safe;
void main() safe
{
shared xs = make();
}
```
Currently, only the conversion to `const shared` is enabled by
uniqueness. I don’t understand that limitation, but I’m not sure
I understand `shared` very well.
Feb 11
On 2/11/26 13:26, Quirin Schroll wrote:
If a pure factory function returns an non-`shared`-type object, that
type should be convertible to `shared` or am I mistaken?
Essentially, this should compile:
```d
int[] make() pure safe;
void main() safe
{
shared xs = make();
}
```
Currently, only the conversion to `const shared` is enabled by
uniqueness. I don’t understand that limitation, but I’m not sure I
understand `shared` very well.
`const shared` works because it is a supertype of `immutable` and
`immutable` works. Even that existing rule is perhaps unsound (depending
on what you consider to be the intended semantics of `shared`):
https://forum.dlang.org/post/jfqsgpkcduptjyryebrq forum.dlang.org
Basically the issue is that you will have unsynchronized memory writes
to some locations that later get transitively typed as `shared`.
Feb 15
On Sunday, 15 February 2026 at 21:20:12 UTC, Timon Gehr wrote:On 2/11/26 13:26, Quirin Schroll wrote:That thread is very interesting. Thanks.If a pure factory function returns an non-`shared`-type object, that type should be convertible to `shared` or am I mistaken? Essentially, this should compile: ```d int[] make() pure safe; void main() safe { shared xs = make(); } ``` Currently, only the conversion to `const shared` is enabled by uniqueness. I don’t understand that limitation, but I’m not sure I understand `shared` very well.`const shared` works because it is a supertype of `immutable` and `immutable` works. Even that existing rule is perhaps unsound (depending on what you consider to be the intended semantics of `shared`): https://forum.dlang.org/post/jfqsgpkcduptjyryebrq forum.dlang.org Basically the issue is that you will have unsynchronized memory writes to some locations that later get transitively typed as `shared`.
Feb 17








Quirin Schroll <qs.il.paperinik gmail.com>