Re: Why are globals set to tls by default? and why is fast code ugly by default?

2023-03-31 Thread bachmeier via Digitalmars-d-learn
On Friday, 31 March 2023 at 16:26:36 UTC, ryuukk_ wrote: I disagree, global mutables are not bad That the same bad advice as telling people to "embrace OOP and multiple inheritance" and all the Java BS "just put your variable into a class and make it static, and then have your singleton to

Re: Why are globals set to tls by default? and why is fast code ugly by default?

2023-03-31 Thread Dennis via Digitalmars-d-learn
On Friday, 31 March 2023 at 16:26:36 UTC, ryuukk_ wrote: That the same bad advice as telling people to "embrace OOP and multiple inheritance" and all the Java BS "just put your variable into a class and make it static, and then have your singleton to access your static variables" I agree tha

New to profiling: dmd -profile; ldc2 --fdmd-trace-functions

2023-03-31 Thread Paul via Digitalmars-d-learn
Thanks in advance for any assistance. As the subject line states I'm just now trying to learn profiling. I have a very small program with 1/2 dozen functions and would like to see where the cpu is spending the most time. I've tried both of these lines with identical results: **ldc2 --fdmd-tr

Re: The Phobos Put

2023-03-31 Thread Paul Backus via Digitalmars-d-learn
On Friday, 31 March 2023 at 02:23:29 UTC, Steven Schveighoffer wrote: There's a certain attempt in phobos in some places to try and ensure code that is going to confuse will not compile. I think this is one of those attempts. Consider that if you pass a slice into `put`, then it returns nothi

Re: Why are globals set to tls by default? and why is fast code ugly by default?

2023-03-31 Thread ryuukk_ via Digitalmars-d-learn
On Friday, 31 March 2023 at 16:02:35 UTC, Dennis wrote: On Friday, 31 March 2023 at 15:52:21 UTC, ryuukk_ wrote: the point i bring is ``__gshared`` is ugly, so we want an ugly language? Good code shouldn't look ugly, but global mutable variables are bad, so it's appropriate that they look ugl

Re: Why are globals set to tls by default? and why is fast code ugly by default?

2023-03-31 Thread Dennis via Digitalmars-d-learn
On Friday, 31 March 2023 at 15:52:21 UTC, ryuukk_ wrote: the point i bring is ``__gshared`` is ugly, so we want an ugly language? Good code shouldn't look ugly, but global mutable variables are bad, so it's appropriate that they look ugly. You can still put a single `__gshared:` at the top o

Re: Why are globals set to tls by default? and why is fast code ugly by default?

2023-03-31 Thread ryuukk_ via Digitalmars-d-learn
On Friday, 31 March 2023 at 10:32:53 UTC, Nick Treleaven wrote: On Sunday, 26 March 2023 at 20:36:37 UTC, ryuukk_ wrote: Golang doesn't even have thread local storage, yet they do very well Go doesn't have a solution to preventing data races at compile time, they just say don't share memory.

Re: Why are globals set to tls by default? and why is fast code ugly by default?

2023-03-31 Thread ryuukk_ via Digitalmars-d-learn
On Friday, 31 March 2023 at 10:26:32 UTC, Nick Treleaven wrote: On Sunday, 26 March 2023 at 20:39:21 UTC, ryuukk_ wrote: if my code doesn't do threads, why should i put my variable into TLS? I don't think writing __gshared is much of a burden. You can use -vtls to print out all variables that

Re: Is this code correct?

2023-03-31 Thread z via Digitalmars-d-learn
On Thursday, 30 March 2023 at 12:59:31 UTC, Dennis wrote: On Thursday, 30 March 2023 at 10:29:25 UTC, z wrote: Is this code correct or logically sound? You need to be exact on what 'correct' is. The comment above `triangleFacesCamera` says: Indicates wether a triangle faces an imaginary vi

Re: Why are globals set to tls by default? and why is fast code ugly by default?

2023-03-31 Thread Nick Treleaven via Digitalmars-d-learn
On Monday, 27 March 2023 at 08:44:41 UTC, wjoe wrote: e.g.: It used to be faster to ... - pre-calculate sin/cos tables, now the memory look up cost more cycles than the calculation itself ... - only redraw the parts of the screen that changed, now the branching is slower than to redraw eve

Re: Why are globals set to tls by default? and why is fast code ugly by default?

2023-03-31 Thread Nick Treleaven via Digitalmars-d-learn
On Sunday, 26 March 2023 at 20:36:37 UTC, ryuukk_ wrote: Golang doesn't even have thread local storage, yet they do very well Go doesn't have a solution to preventing data races at compile time, they just say don't share memory. But what if you accidentally share memory? That is *very* easy t

Re: Why are globals set to tls by default? and why is fast code ugly by default?

2023-03-31 Thread Nick Treleaven via Digitalmars-d-learn
On Sunday, 26 March 2023 at 20:39:21 UTC, ryuukk_ wrote: if my code doesn't do threads, why should i put my variable into TLS? I don't think writing __gshared is much of a burden. You can use -vtls to print out all variables that are TLS, and add that to an automated test to check you don't h

Re: Why are globals set to tls by default? and why is fast code ugly by default?

2023-03-31 Thread Nick Treleaven via Digitalmars-d-learn
On Sunday, 26 March 2023 at 20:39:21 UTC, ryuukk_ wrote: if my code doesn't do threads, why should i put my variable into TLS? I don't think writing __gshared is a huge burden. You can use -vtls to print out all variables that are TLS, and add that to an automated test to check you don't have