How to assign and compare arrays to SumType?

2024-06-11 Thread confuzzled via Digitalmars-d-learn
Comparison between a Variant and an array is straightforward. How does one accomplish the same between a SumType and an array? ```d import std.variant; import std.sumtype; import std.stdio; struct S { SumType!(double[]) data; // {1} } void main() { Variant v = [1.7, 2.7, 3.7, 4.7, 5.7

Re: How to assign and compare arrays to SumType?

2024-06-11 Thread confuzzled via Digitalmars-d-learn
On Tuesday, 11 June 2024 at 16:41:46 UTC, confuzzled wrote: Also, assuming that {1} read "SumType!(double)[] data;", what would be the proper way to accomplish the assignment at {2} and the subsequent comparison. Not sure how to do solve the fist part of the question yet but I was able to

Re: How to assign and compare arrays to SumType?

2024-06-11 Thread confuzzled via Digitalmars-d-learn
On Tuesday, 11 June 2024 at 16:41:46 UTC, confuzzled wrote: Comparison between a Variant and an array is straightforward. How does one accomplish the same between a SumType and an array? Okay, this is what I came up with. Just a sanity check please. Did I do this correctly? Is there somethin

ImportC linking issue

2022-11-10 Thread confuzzled via Digitalmars-d-learn
Wondering if someone can help me with this. Mr. Adam D. Ruppe got me 90% there, but I'm a little lost after reaching the 99% mark. I want to use XLSX I/O to manipulate excel spreadsheets. I've cloned, built, and installed the library. And with the help of Adam, I am now able to import it and l

Re: ImportC linking issue

2022-11-11 Thread confuzzled via Digitalmars-d-learn
On Friday, 11 November 2022 at 03:15:17 UTC, confuzzled wrote: When I try to compile it, I get a slew of errors about undefined symbols. It wasn't finding libexpat and libminizip so I copied those to my work directory and tried again. With that, most of the errors disappeared. The remaining one

Re: ImportC linking issue

2022-11-12 Thread confuzzled via Digitalmars-d-learn
On Saturday, 12 November 2022 at 08:43:13 UTC, Mike Parker wrote: On Saturday, 12 November 2022 at 02:45:52 UTC, confuzzled wrote: The linker doesn't care if the libraries are C or D, and the compiler is only involved in that you can pass flags to the linker via the compiler command line.

Re: ImportC linking issue

2022-11-12 Thread confuzzled via Digitalmars-d-learn
On Saturday, 12 November 2022 at 11:44:06 UTC, Mike Parker wrote: On Saturday, 12 November 2022 at 10:02:12 UTC, confuzzled wrote: On Saturday, 12 November 2022 at 08:43:13 UTC, Mike Parker wrote: On Saturday, 12 November 2022 at 02:45:52 UTC, confuzzled wrote: The linker doesn't care if the

Re: ImportC linking issue

2022-11-12 Thread confuzzled via Digitalmars-d-learn
On Saturday, 12 November 2022 at 12:48:40 UTC, confuzzled wrote: Right, so I figured that the dependencies for for libxlsxio_read would be resolved when it was being compiled/linked. Therefore, when I used it later, I would just need to import its and include it on the command line. I didn't

macOS Sonoma Linker Issue

2023-10-03 Thread confuzzled via Digitalmars-d-learn
Any known workaround for this most recent issue on macOS Sonoma? The file I'm compiling contains a blank main() without any imports but this error shows up on everything I've attempted to compile since upgrading to Sonoma. (dmd-2.105.2) confuzzled@test ~ % dmd add ld: multiple errors: symbol c

Re: macOS Sonoma Linker Issue

2023-10-04 Thread confuzzled via Digitalmars-d-learn
On Wednesday, 4 October 2023 at 11:01:08 UTC, Johan wrote: Try passing `-ld_classic` to the linker. (`dmd -L-ld_classic`) https://github.com/ldc-developers/ldc/issues/4501#issuecomment-1738295459 -Johan Thanks. This did the trick.

What are the best available D (not C) File input/output options?

2023-11-02 Thread confuzzled via Digitalmars-d-learn
I've ported a small script from C to D. The original C version takes roughly 6.5 minutes to parse a 12G file while the port originally took about 48 minutes. My naïve attempt to improve the situation pushed it over an hour and 15 minutes. However, replacing std.stdio:File with core.stdc.stdio:F

Re: What are the best available D (not C) File input/output options?

2023-11-05 Thread confuzzled via Digitalmars-d-learn
Good morning, First, thanks to you, Steve, and Julian for responding to my inquiry. On 11/3/23 4:59 AM, Sergey wrote: On Thursday, 2 November 2023 at 15:46:23 UTC, confuzzled wrote: I've ported a small script from C to D. The original C version takes roughly 6.5 minutes to parse a 12G file w

Re: What are the best available D (not C) File input/output options?

2023-11-05 Thread confuzzled via Digitalmars-d-learn
On 11/3/23 2:30 AM, Steven Schveighoffer wrote: On Thursday, 2 November 2023 at 15:46:23 UTC, confuzzled wrote: You should use a buffering library like iopipe to write properly here (it handles the encoding of text for you). Thanks Steve, I will try that.

union default initialization values

2023-12-05 Thread confuzzled via Digitalmars-d-learn
Given the following union union F { double x; struct { ulong lo; ulong hi; } } I do not understand the output below. Please clarify. import std.stdio; void main() { F fp; fp.lo.writeln; // Why is this not zero? How is this value derived? fp.hi.writeln; //

Re: union default initialization values

2023-12-05 Thread confuzzled via Digitalmars-d-learn
On 12/6/23 4:28 AM, Adam D Ruppe wrote: On Tuesday, 5 December 2023 at 19:24:51 UTC, confuzzled wrote: Given the following union union F {     double x;     struct {     ulong lo;     ulong hi;     } } The default value of this would be `double.init`, since the first member of the un

Re: union default initialization values

2023-12-05 Thread confuzzled via Digitalmars-d-learn
On 12/6/23 4:47 AM, H. S. Teoh wrote: On Wed, Dec 06, 2023 at 04:24:51AM +0900, confuzzled via Digitalmars-d-learn wrote: [...] Also, if you don't understand how floating-point in computers work, I highly recommend reading this: https://docs.oracle.com/cd/E19957-01/806

request assistance resolving curl error

2024-03-26 Thread confuzzled via Digitalmars-d-learn
Hello all, I have two scripts. I copied the first directly from the alpaca website and massaged it with etc.c.curl until it compiled in D. The result is that it creates the order and returns the result to stdout. In the second script, I tried to use std.net.curl but cannot get it to work. T

Re: request assistance resolving curl error

2024-03-27 Thread confuzzled via Digitalmars-d-learn
On 3/26/24 8:44 PM, Andrea Fontana wrote: On Tuesday, 26 March 2024 at 07:13:24 UTC, confuzzled wrote: I think you should use the HTTP interface, did you check this docs? https://dlang.org/phobos/std_net_curl.html#.HTTP https://dlang.org/phobos/std_net_curl.html#.HTTP.addRequestHeader Andrea

Inplace lambda execution

2025-03-28 Thread confuzzled via Digitalmars-d-learn
I apologize for the newbie question but how do I get the lambda the following to execute and return a string instead of the function pointer?: private static immutable string[] typeNames = [staticMap!(T => typeof(T).stringof, TypeSeq)]; I currently get this error: ```D sumtype.d(61): Error:

Re: Pointer vs Ref

2025-07-04 Thread confuzzled via Digitalmars-d-learn
On 6/15/25 9:06 AM, Steven Schveighoffer wrote: On Monday, 9 June 2025 at 07:24:41 UTC, confuzzled wrote: Hello community, Is it possible to accomplish the following using ref instead of pointers? If so, please share an example. A ref cannot be a member of a type. But ref can be returned by

Interact with local variables in asm block

2025-07-04 Thread confuzzled via Digitalmars-d-learn
Good day all, What is the proper way to assign to accomplish this? ulong rdtsc() { ulong result; uint* res = cast(uint*) &result; asm { rdtsc; // Puts result in edx:eax // Cast our ulong's address to a 32-bit integer pointer // and move the register values i

Re: Interact with local variables in asm block

2025-07-04 Thread confuzzled via Digitalmars-d-learn
On 7/5/25 1:06 AM, confuzzled wrote: ulong rdtsc() {     ulong result;     uint* res = cast(uint*) &result;     asm {     rdtsc;  // Puts result in edx:eax     // Cast our ulong's address to a 32-bit integer pointer     // and move the register values into the correct memory lo

Pointer vs Ref

2025-06-09 Thread confuzzled via Digitalmars-d-learn
Hello community, Is it possible to accomplish the following using ref instead of pointers? If so, please share an example. import std.stdio; // Represents our large, external data source (like TimeSeries) struct DataSource { int[3] data; } // Represents our Backtester engine struct Engin

Re: Pointer vs Ref

2025-06-11 Thread confuzzled via Digitalmars-d-learn
On 6/10/25 2:17 AM, Ali Çehreli wrote: On 6/9/25 12:24 AM, confuzzled wrote: > Is it possible to accomplish the following using ref instead of > pointers? Your example is a good case for a pointer. Was there a reason why a reference should be used? Just exploring the realm of possibilities

Re: Pointer vs Ref

2025-06-11 Thread confuzzled via Digitalmars-d-learn
On 6/9/25 11:16 PM, monkyyy wrote: On Monday, 9 June 2025 at 07:24:41 UTC, confuzzled wrote: Hello community, Is it possible to accomplish the following using ref instead of pointers? If so, please share an example. The hard part is the `foreach` the simple answer is throw a ref before `v