Re: synchronized/shared associative array .require error

2022-09-06 Thread frame via Digitalmars-d-learn
On Tuesday, 6 September 2022 at 10:28:53 UTC, Loara wrote: On Saturday, 3 September 2022 at 14:07:58 UTC, frame wrote: Not exactly, a synchronized class member function becomes automatically a shared one. This is not present in official documentation so other compilers different from `dmd`

Re: synchronized/shared associative array .require error

2022-09-06 Thread Loara via Digitalmars-d-learn
On Saturday, 3 September 2022 at 14:07:58 UTC, frame wrote: Not exactly, a synchronized class member function becomes automatically a shared one. This is not present in official documentation so other compilers different from `dmd` aren't forced to assume it. This should be consider an

Re: synchronized/shared associative array .require error

2022-09-05 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/4/22 11:24 PM, cc wrote: On Saturday, 3 September 2022 at 14:37:16 UTC, Steven Schveighoffer wrote: On 9/2/22 3:15 PM, cc wrote: Tried casting away shared as a workaround but I assume that will cause some kind of TLS catastrophe. I think it will be fine, but you may have an issue.

Re: synchronized/shared associative array .require error

2022-09-04 Thread cc via Digitalmars-d-learn
On Saturday, 3 September 2022 at 14:37:16 UTC, Steven Schveighoffer wrote: On 9/2/22 3:15 PM, cc wrote: Tried casting away shared as a workaround but I assume that will cause some kind of TLS catastrophe. I think it will be fine, but you may have an issue. You are returning a non-shared

Re: synchronized/shared associative array .require error

2022-09-03 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/2/22 3:15 PM, cc wrote: Tried casting away shared as a workaround but I assume that will cause some kind of TLS catastrophe. I think it will be fine, but you may have an issue. You are returning a non-shared `VAL`, but your class is `shared`, which means `table`, and all the `VAL`

Re: synchronized/shared associative array .require error

2022-09-03 Thread frame via Digitalmars-d-learn
On Saturday, 3 September 2022 at 09:49:54 UTC, Loara wrote: In current version of D language `synchronized` and `shared` are independent. In particular `shared` should be used only for basic types like integers for which atomic operations are well defined, and not for classes. Not exactly,

Re: synchronized/shared associative array .require error

2022-09-03 Thread Loara via Digitalmars-d-learn
On Friday, 2 September 2022 at 19:15:45 UTC, cc wrote: ```d synchronized class SyncTable(KEY, VAL) { private VAL[KEY] table; auto require(KEY key) { return table.require(key); } } auto table = new shared SyncTable!(string, string); table.require("abc");

synchronized/shared associative array .require error

2022-09-02 Thread cc via Digitalmars-d-learn
```d synchronized class SyncTable(KEY, VAL) { private VAL[KEY] table; auto require(KEY key) { return table.require(key); } } auto table = new shared SyncTable!(string, string); table.require("abc"); ``` Fails to compile: ``` // Error: none of the