digitalmars.D.learn - Passing delegate indirectly to createLowLevelThread doesn't work
- Tejas (13/13) Jul 26 2021 ```d
- Paul Backus (5/18) Jul 26 2021 The delegate must be `nothrow`:
- Tejas (4/25) Jul 26 2021 Doesn't seem to matter. I tried that beforehand. And even if it
- Tejas (4/31) Jul 26 2021 Sorry, it seems to work now.
- JG (16/43) Jul 26 2021 It does work for me. To me running the following explains why:
- Tejas (4/33) Jul 26 2021 Yeah after reading the error diagnostics carefully I realized
- Adam D Ruppe (11/14) Jul 26 2021 Well, technically, it is inferred there too, but since you
- Tejas (2/16) Jul 26 2021 Thank you very much for further explaining this :D
```d import std; import core.thread.osthread; void delegate() f; void main() { void func(){} f = &func; createLowLevelThread(&func, 2<<30);//works createLowLevelThread(f, 2<<30);// doesn't work!! } ``` Can someone help?
Jul 26 2021
On Monday, 26 July 2021 at 15:29:26 UTC, Tejas wrote:```d import std; import core.thread.osthread; void delegate() f; void main() { void func(){} f = &func; createLowLevelThread(&func, 2<<30);//works createLowLevelThread(f, 2<<30);// doesn't work!! } ``` Can someone help?The delegate must be `nothrow`: ```d void delegate() nothrow f; ```
Jul 26 2021
On Monday, 26 July 2021 at 15:42:44 UTC, Paul Backus wrote:On Monday, 26 July 2021 at 15:29:26 UTC, Tejas wrote:Doesn't seem to matter. I tried that beforehand. And even if it did why does passing it directly work without explicitly qualifying it as nothrow then?```d import std; import core.thread.osthread; void delegate() f; void main() { void func(){} f = &func; createLowLevelThread(&func, 2<<30);//works createLowLevelThread(f, 2<<30);// doesn't work!! } ``` Can someone help?The delegate must be `nothrow`: ```d void delegate() nothrow f; ```
Jul 26 2021
On Monday, 26 July 2021 at 16:46:40 UTC, Tejas wrote:On Monday, 26 July 2021 at 15:42:44 UTC, Paul Backus wrote:Sorry, it seems to work now. But why didn't it fail when I didn't qualify ```func``` as nothrow?On Monday, 26 July 2021 at 15:29:26 UTC, Tejas wrote:Doesn't seem to matter. I tried that beforehand. And even if it did why does passing it directly work without explicitly qualifying it as nothrow then?```d import std; import core.thread.osthread; void delegate() f; void main() { void func(){} f = &func; createLowLevelThread(&func, 2<<30);//works createLowLevelThread(f, 2<<30);// doesn't work!! } ``` Can someone help?The delegate must be `nothrow`: ```d void delegate() nothrow f; ```
Jul 26 2021
On Monday, 26 July 2021 at 16:46:40 UTC, Tejas wrote:On Monday, 26 July 2021 at 15:42:44 UTC, Paul Backus wrote:It does work for me. To me running the following explains why: ```d import std; import core.thread.osthread; void delegate() f; void main() { void func(){} f = &func; pragma(msg,typeof(&func)); pragma(msg,typeof(f)); createLowLevelThread(&func, 2<<30);//works //createLowLevelThread(f, 2<<30);// doesn't work!! } ```On Monday, 26 July 2021 at 15:29:26 UTC, Tejas wrote:Doesn't seem to matter. I tried that beforehand. And even if it did why does passing it directly work without explicitly qualifying it as nothrow then?```d import std; import core.thread.osthread; void delegate() f; void main() { void func(){} f = &func; createLowLevelThread(&func, 2<<30);//works createLowLevelThread(f, 2<<30);// doesn't work!! } ``` Can someone help?The delegate must be `nothrow`: ```d void delegate() nothrow f; ```
Jul 26 2021
On Monday, 26 July 2021 at 17:01:13 UTC, JG wrote:On Monday, 26 July 2021 at 16:46:40 UTC, Tejas wrote:Yeah after reading the error diagnostics carefully I realized that the compiler is inferring many attributes when passing ```func``` directly but not when passing via delegateOn Monday, 26 July 2021 at 15:42:44 UTC, Paul Backus wrote:It does work for me. To me running the following explains why: ```d import std; import core.thread.osthread; void delegate() f; void main() { void func(){} f = &func; pragma(msg,typeof(&func)); pragma(msg,typeof(f)); createLowLevelThread(&func, 2<<30);//works //createLowLevelThread(f, 2<<30);// doesn't work!! } ```On Monday, 26 July 2021 at 15:29:26 UTC, Tejas wrote:Doesn't seem to matter. I tried that beforehand. And even if it did why does passing it directly work without explicitly qualifying it as nothrow then?[...]The delegate must be `nothrow`: ```d void delegate() nothrow f; ```
Jul 26 2021
On Monday, 26 July 2021 at 17:14:45 UTC, Tejas wrote:Yeah after reading the error diagnostics carefully I realized that the compiler is inferring many attributes when passing ```func``` directly but not when passing via delegateWell, technically, it is inferred there too, but since you specified `void delegate()` it implicitly casts to that and drops the detail. Similar to the difference between like Object o = new MyClass; // now o is still Object since the class implicitly casted and thus drops the extensions in the child class and auto c = new MyClass; // no conversion requested there, c has the full type of MyClass
Jul 26 2021
On Monday, 26 July 2021 at 17:21:04 UTC, Adam D Ruppe wrote:On Monday, 26 July 2021 at 17:14:45 UTC, Tejas wrote:Thank you very much for further explaining this :DYeah after reading the error diagnostics carefully I realized that the compiler is inferring many attributes when passing ```func``` directly but not when passing via delegateWell, technically, it is inferred there too, but since you specified `void delegate()` it implicitly casts to that and drops the detail. Similar to the difference between like Object o = new MyClass; // now o is still Object since the class implicitly casted and thus drops the extensions in the child class and auto c = new MyClass; // no conversion requested there, c has the full type of MyClass
Jul 26 2021