Re: OK to do bit-packing with GC pointers?

2022-07-22 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/22/22 2:34 PM, Ben Jones wrote: Can you elaborate on why it's probably OK in practice? Because the GC deals with interior pointers just fine. Blocks with the "no interior" bit set are very rare, and for only specialized use, so normally this should not be a problem. I have argued in

Re: Expanding CTFE code during compilation

2022-07-22 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/22/22 3:22 PM, Azi Hassan wrote: Oh, interesting syntax. I was thinking something along the lines of ```D template printEnum(...) {     version(debug) {     ... // everything we already did     } else {     enum printEnum(alias x) = x;     } } ``` But I like yours better. `

Re: Expanding CTFE code during compilation

2022-07-22 Thread Azi Hassan via Digitalmars-d-learn
On Wednesday, 20 July 2022 at 14:11:52 UTC, Dennis wrote: On Wednesday, 20 July 2022 at 00:33:06 UTC, Azi Hassan wrote: Where did you find it though ? I checked dmd --help and man dmd before making this thread, but to no avail. It was implemented as an internal debugging tool, not a documente

Re: Expanding CTFE code during compilation

2022-07-22 Thread Azi Hassan via Digitalmars-d-learn
On Wednesday, 20 July 2022 at 01:15:44 UTC, Steven Schveighoffer wrote: On 7/19/22 8:57 PM, Steven Schveighoffer wrote: There's a slight bloat in the compiler symbol table when  but other than that it should be effective. Obviously I didn't finish that thought... "when `-debug` isn't used on

Re: OK to do bit-packing with GC pointers?

2022-07-22 Thread Ben Jones via Digitalmars-d-learn
On Friday, 22 July 2022 at 16:57:21 UTC, Steven Schveighoffer wrote: It's specifically undefined behavior by the spec, but in practice, I think it will work, as long as the block you have isn't marked as not allowing interior pointers. See: https://dlang.org/spec/garbage.html#pointers_and_gc

Re: OK to do bit-packing with GC pointers?

2022-07-22 Thread H. S. Teoh via Digitalmars-d-learn
On Fri, Jul 22, 2022 at 04:50:44PM +, Ben Jones via Digitalmars-d-learn wrote: > I'm looking to store a pointer to one of 2 unrelated (no inheritance > relationship) classes and use the LSb to track which type I have. Is > this going to cause any problems with the GC? For one of the classes

Re: OK to do bit-packing with GC pointers?

2022-07-22 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/22/22 12:50 PM, Ben Jones wrote: I'm looking to store a pointer to one of 2 unrelated (no inheritance relationship) classes and use the LSb to track which type I have.  Is this going to cause any problems with the GC? For one of the classes I'll have a "pointer" to 1 byte past the start of

OK to do bit-packing with GC pointers?

2022-07-22 Thread Ben Jones via Digitalmars-d-learn
I'm looking to store a pointer to one of 2 unrelated (no inheritance relationship) classes and use the LSb to track which type I have. Is this going to cause any problems with the GC? For one of the classes I'll have a "pointer" to 1 byte past the start of the object. It seems like std.bitma

Re: mixin template bug with opBinary?

2022-07-22 Thread Paul Backus via Digitalmars-d-learn
On Friday, 22 July 2022 at 12:33:37 UTC, Anthony Quizon wrote: I get: ``` foo.d(16): Error: mixin `foo.B.opBi!(B, ["+":function (B a, B b) pure nothrow @nogc @safe => a])` does not match template declaration `opBi(A, A function(A, A)[string] f0)` ``` Is this a bug or am I doing something wron

Re: mixin template bug with opBinary?

2022-07-22 Thread Anthony Quizon via Digitalmars-d-learn
On Friday, 22 July 2022 at 12:56:44 UTC, Adam D Ruppe wrote: ``` mixin template opBi( alias f0 ) { static foreach (k, f; f0) { typeof(this) opBinary(string op: k)(typeof(this) r) { return f(this, r); } } } ``` Thanks, this seems to do the trick.

Re: mixin template bug with opBinary?

2022-07-22 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/22/22 8:33 AM, Anthony Quizon wrote: Hello, I'm trying to create a mixin for quick binary operator overloads by passing in types with a corresponding associative array of strings to functions. However, the code I currently have: ``` module foo; mixin template opBi(     A, A function(A

Re: mixin template bug with opBinary?

2022-07-22 Thread Adam D Ruppe via Digitalmars-d-learn
On Friday, 22 July 2022 at 12:33:37 UTC, Anthony Quizon wrote: Is this a bug or am I doing something wrong? I think this is a bug. The compiler must not take well to this pattern, maybe the assoc array template argument, but idk. It looks like the first type used gets cached and reused even i

Vibe.d conectting to a mongo replica set

2022-07-22 Thread Bogdan Szabo via Digitalmars-d-learn
Hello everyone, I recently seen that vibe.d can't connect to a mongo replica set and it looks that is a missing feature in the library: https://github.com/vibe-d/vibe.d/blob/7604eea772b1a733f7bfd16591ddc5bd37850bd9/mongodb/vibe/db/mongo/connection.d#L152 Does anyone uses vibe.d with a replica

mixin template bug with opBinary?

2022-07-22 Thread Anthony Quizon via Digitalmars-d-learn
Hello, I'm trying to create a mixin for quick binary operator overloads by passing in types with a corresponding associative array of strings to functions. However, the code I currently have: ``` module foo; mixin template opBi( A, A function(A, A)[string] f0, ) { static foreach (k,

Re: Working with arrays (flatten, transpose, verfify rectangular)

2022-07-22 Thread anonymouse via Digitalmars-d-learn
On Friday, 22 July 2022 at 05:17:49 UTC, anonymouse wrote: On Wednesday, 20 July 2022 at 09:18:29 UTC, anonymouse wrote: As for task 3, while I understand the concept of transposing a matrix, I'm not sure how to even begin. By not knowing how to begin, I mean that I don't know how to gene