msghdr and cmsghdr mismatch for alpine musl
`import core.sys.posix.sys.socket : msghdr, cmsghdr, iovec;` `msg_iovlen`, `msg_controllen`, `cmsg_len` is ulong for x86-64 in druntime. in alpine musl, they are int, socklen_t(uint), socklen_t(uint). Is this mismatch can cause problems is I use related api ?
Re: interface opEquals
On Friday, 24 November 2023 at 17:39:10 UTC, Antonio wrote: ... Dunno if this might help, but I noticed that `==` sometimes calls `opEquals(const Object) const` instead of overload defined on class/interface, you might try and override it as well, and delegate to your overload that deals directly with `IOpt`. Best regards, Alexandru.
Re: interface opEquals
On Thursday, 23 November 2023 at 21:52:56 UTC, Jonathan M Davis wrote: I'd have to take the time to study your code in detail to see whether what exactly you're seeing makes sense or not ... My apologies... I should have proposed a more specific example. ```d interface IOpt { bool opEquals(IOpt other) const @safe pure; } class None : IOpt { bool opEquals(IOpt other) const @safe pure => true; } void main() { None a = new None(), b = new None(); IOpt a2 = a, b2 = b; assert(a == b); assert(a2 == a); assert(b2 == b); assert(a2 == b2); // fails!!! } ``` == on classes results in the free function, opEquals, in object.d being called. That function does a variety of checks such as checking whether either reference is null (to avoid dereferencing null) and using is to compare the address of the class references first (to avoid calling the class' opEquals if both references are to the same object). It also makes sure that both rhs.opEquals(lhs) and lhs.opEquals(rhs) are true for == to be true to avoid subtle bugs that can come into play when comparing a base class against a derived class. https://github.com/dlang/dmd/blob/master/druntime/src/object.d#L269 Replacing ```interface``` by ```abstract class``` removes the problem. But I have not enough D knowledge to discover why interface version is not working Thanks Antonio
Re: D: Convert/parse uint integer to string. (@nogc)
On Friday, 24 November 2023 at 09:35:00 UTC, BoQsc wrote: I tried to look into https://dlang.org/phobos/std_conv.html Most of the functions inside `std.conv` seem to be dependant on [Garbage Collection](https://dlang.org/spec/garbage.html). And I couldn't find a straightforward way to produce a `string` value out of `uint` value. How to convert or parse `uint` value to a `string` in `@nogc` way? I guess there are third-party libraries doing this. One would use stdc functions such as sprintf. Probably, there should be a more d-ish way. ``` import core.stdc.stdio : sprintf; import core.stdc.math : log10; import std.exception : assumeUnique; import std.stdio : writeln; size_t nod(int num){ return cast(size_t)((num==0)?1:log10(num)+1); } void main() { int myint = 23; char[80] str; sprintf(str.ptr, "%d", myint); string _dstring = str[0..nod(myint)].assumeUnique; writeln(_dstring); } ```
D: Convert/parse uint integer to string. (@nogc)
I tried to look into https://dlang.org/phobos/std_conv.html Most of the functions inside `std.conv` seem to be dependant on [Garbage Collection](https://dlang.org/spec/garbage.html). And I couldn't find a straightforward way to produce a `string` value out of `uint` value. How to convert or parse `uint` value to a `string` in `@nogc` way?