Re: How to unpack a tuple into multiple variables?

2024-02-07 Thread Menjanahary R. R. via Digitalmars-d-learn
On Wednesday, 7 February 2024 at 05:03:09 UTC, Gary Chike wrote: ... But overall it's an elegant way to indirectly add names to tuples in D for ergonomic access. Nice find! --- Refactored it a bit to have a ready to run and easy to grasp code. Enjoy! ```d import std.stdio : writefln; import

Re: length's type.

2024-02-07 Thread mw via Digitalmars-d-learn
On Thursday, 8 February 2024 at 05:56:57 UTC, Kevin Bailey wrote: I don't think it's productive to compare the behavior to C. C is now 50 years old. One would hope that D has learned a few things in that time. How many times does the following loop print? I ran into this twice doing the AoC

Re: length's type.

2024-02-07 Thread Kevin Bailey via Digitalmars-d-learn
On Wednesday, 7 February 2024 at 20:13:40 UTC, Gary Chike wrote: On Wednesday, 7 February 2024 at 20:08:24 UTC, Gary Chike wrote: On Wednesday, 7 February 2024 at 19:32:56 UTC, Gary Chike wrote: double c = (double)sumArray(a, aLength) / aLength; If I don't cast explicitly: `double c =

Re: How to get the client's MAC address in Vibe

2024-02-07 Thread Mengu via Digitalmars-d-learn
On Wednesday, 7 February 2024 at 22:16:54 UTC, Alexander Zhirov wrote: Is there a way to identify a client by MAC address when using the Vibe library? The `NetworkAddress` [structure](https://vibed.org/api/vibe.core.net/NetworkAddress) does not provide such features. Or did I miss something?

How to get the client's MAC address in Vibe

2024-02-07 Thread Alexander Zhirov via Digitalmars-d-learn
Is there a way to identify a client by MAC address when using the Vibe library? The `NetworkAddress` [structure](https://vibed.org/api/vibe.core.net/NetworkAddress) does not provide such features. Or did I miss something?

Re: length's type.

2024-02-07 Thread Gary Chike via Digitalmars-d-learn
On Wednesday, 7 February 2024 at 20:08:24 UTC, Gary Chike wrote: On Wednesday, 7 February 2024 at 19:32:56 UTC, Gary Chike wrote: double c = (double)sumArray(a, aLength) / aLength; If I don't cast explicitly: `double c = sumArray(a, aLength) / aLength;` then I will get a similar

Re: length's type.

2024-02-07 Thread Gary Chike via Digitalmars-d-learn
On Wednesday, 7 February 2024 at 19:32:56 UTC, Gary Chike wrote: On Wednesday, 7 February 2024 at 19:20:12 UTC, Gary Chike wrote: The output wasn't quite right. So I tweaked it a bit: ```c long sumArray(long arr[], size_t size) { long total = 0; for (size_t i = 0; i < size; ++i) {

Re: length's type.

2024-02-07 Thread Gary Chike via Digitalmars-d-learn
On Wednesday, 7 February 2024 at 19:20:12 UTC, Gary Chike wrote: I just had to transcribe this to C just for grins :D ```c #include int sumArray(int arr[], size_t size) { int total = 0; for (size_t i = 0; i < size; ++i) { total += arr[i]; } return total; } int

Re: length's type.

2024-02-07 Thread Gary Chike via Digitalmars-d-learn
On Sunday, 28 January 2024 at 17:25:49 UTC, mw wrote: See the result here: https://forum.dlang.org/post/cagloplexjfzubncx...@forum.dlang.org I knew this outlandish output had to do with mixing of signed and unsigned types with resulting overflow. But I like the way Anthropic Claude2

Re: How to unpack a tuple into multiple variables?

2024-02-07 Thread Gary Chike via Digitalmars-d-learn
On Wednesday, 7 February 2024 at 13:18:00 UTC, ryuukk_ wrote: There was a DIP for native tuples in D, hopefully we'll get it soon I just wanted to define DIP for newbs since we're in a new users thread. If they look it up, they will see: Dependency Inversion Principle, Dip programming

Re: std.uni CodepointSet toString

2024-02-07 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
On 08/02/2024 6:11 AM, H. S. Teoh wrote: Do we know why the compiler isn't getting it right? Shouldn't we be fixing it instead of just turning off elision completely? Of course we should. It has been reported multiple times, with different examples trigger the switch symbol error.

Re: std.uni CodepointSet toString

2024-02-07 Thread H. S. Teoh via Digitalmars-d-learn
On Thu, Feb 08, 2024 at 05:44:59AM +1300, Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn wrote: > On 08/02/2024 5:36 AM, Carl Sturtivant wrote: [...] > > ``` > > $ dmd --help | grep allinst > >   -allinst  generate code for all template instantiations > > ``` > > Unclear

Re: std.uni CodepointSet toString

2024-02-07 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
On 08/02/2024 5:36 AM, Carl Sturtivant wrote: On Wednesday, 7 February 2024 at 11:49:20 UTC, Richard (Rikki) Andrew Cattermole wrote: ``` undefined reference to `_D4core9exception__T15__switch_errorTZQsFNaNbNiNeAyamZv' collect2: error: ld returned 1 exit status Error: linker exited with

Re: std.uni CodepointSet toString

2024-02-07 Thread Carl Sturtivant via Digitalmars-d-learn
On Wednesday, 7 February 2024 at 11:49:20 UTC, Richard (Rikki) Andrew Cattermole wrote: ``` undefined reference to `_D4core9exception__T15__switch_errorTZQsFNaNbNiNeAyamZv' collect2: error: ld returned 1 exit status Error: linker exited with status 1 ``` Use ``-allinst``, that is a template

Re: How to unpack a tuple into multiple variables?

2024-02-07 Thread ryuukk_ via Digitalmars-d-learn
On Wednesday, 7 February 2024 at 05:29:45 UTC, Gary Chike wrote: On Wednesday, 7 February 2024 at 01:17:33 UTC, zjh wrote: Officially, there should be an unpacking solution, like ```d //C++ auto[a,b,c]=tuple. ``` Wouldn't that be nice? I hope a clean and terse direct-implementation comes in

Re: std.uni CodepointSet toString

2024-02-07 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
https://issues.dlang.org/show_bug.cgi?id=20802

Re: std.uni CodepointSet toString

2024-02-07 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
On 07/02/2024 7:27 PM, Carl Sturtivant wrote: Need help working around a linkage problem. ```d import std.uni, std.conv, std.stdio, std.format; void main() { //auto c1 = unicode.InBasic_latin; auto c1 = CodepointSet('a','z'+1); writeln(c1.to!string); writeln(format("%d",