linux dynamic library __gshared var

2024-01-07 Thread d007 via Digitalmars-d-learn
I just notice the __gshared is cross process shared.   I want a 
var exits in one process, but shared for multi thread with atomic 
for __gshared library.  how can I do this with d ?






Re: Generating custom toString for structs

2024-01-07 Thread Paul Backus via Digitalmars-d-learn

On Sunday, 7 January 2024 at 09:49:36 UTC, Renato wrote:

Is the above a "good" way to do this?


It looks ok to me. There are some minor changes I would make, 
like using `typeof(this)` instead of `S` to refer to the type of 
the struct you're mixing it into, but the overall approach is 
fine.


Are there libraries (or even something in Phobos?) that already 
provide some mixins or equivalent functionality?


For reference, I wanted something like Java [Lombok's ToString 
annotation](https://projectlombok.org/features/ToString), also 
present in 
[Groovy](https://docs.groovy-lang.org/latest/html/gapi/groovy/transform/ToString.html).


The [`boilerplate` package][1] has a [`GenerateToString` 
mixin][2] that looks pretty similar to the examples you linked.


[1]: https://code.dlang.org/packages/boilerplate
[2]: 
https://boilerplate.dpldocs.info/v1.9.1/boilerplate.autostring.GenerateToString.html