Re: Debug help - opDispatch - unknown member function

2025-09-09 Thread Brother Bill via Digitalmars-d-learn
On Tuesday, 9 September 2025 at 00:45:00 UTC, monkyyy wrote: On Tuesday, 9 September 2025 at 00:40:31 UTC, Brother Bill wrote: https://tour.dlang.org/tour/en/gems/opdispatch-opapply This states: "Any unknown member function call to that type is passed to opDispatch, passing the unknown member

Re: Debug help - opDispatch - unknown member function

2025-09-09 Thread Steven Schveighoffer via Digitalmars-d-learn
On Tuesday, 9 September 2025 at 20:08:06 UTC, monkyyy wrote: On Tuesday, 9 September 2025 at 19:17:11 UTC, Steven Schveighoffer wrote: In short `opDispatch` only is valid if it compiles. If it doesn't compile, it's as if it doesn't exist. Yours still thinking declaratively, that cant be true

Re: Debug help - opDispatch - unknown member function

2025-09-09 Thread monkyyy via Digitalmars-d-learn
On Tuesday, 9 September 2025 at 19:17:11 UTC, Steven Schveighoffer wrote: In short `opDispatch` only is valid if it compiles. If it doesn't compile, it's as if it doesn't exist. Yours still thinking declaratively, that cant be true. The best description of its behavior is that it discards er

Re: Debug help - opDispatch - unknown member function

2025-09-09 Thread Steven Schveighoffer via Digitalmars-d-learn
On Tuesday, 9 September 2025 at 00:40:31 UTC, Brother Bill wrote: ``` c:\dev\D\D_templates_tutorial\toy1\source\app.d(8): Error: no property `callHome` for `l` of type `app.CallLogger!(C)` l.callHome("foo", "bar"); ^ ``` You might be expecting `opDispatch` inside `CallLogger` to try

Re: Debug help - opDispatch - unknown member function

2025-09-09 Thread IchorDev via Digitalmars-d-learn
On Tuesday, 9 September 2025 at 12:04:07 UTC, Brother Bill wrote: When commenting out the callHome() in struct C, it fails. You can't call a function that doesn't exist. When the function doesn't exist, you can't call it. Obviously if callHome() is explicitly created, it works. *Explicitl

Re: Debug help - opDispatch - unknown member function

2025-09-09 Thread Brother Bill via Digitalmars-d-learn
On Tuesday, 9 September 2025 at 09:59:40 UTC, Dejan Lekic wrote: Hopefully this slightly modified, and commented version of your original code will help you understand why your mixin is failing: ```d import std.stdio; void main() { CallLogger!C l; l.callA(1, 2); l.callB(&quo

Re: Debug help - opDispatch - unknown member function

2025-09-09 Thread Brother Bill via Digitalmars-d-learn
On Tuesday, 9 September 2025 at 01:24:59 UTC, monkyyy wrote: ```d import std; struct Vector(int N,T,string fields){ static foreach(I;0..N){ mixin("T "~fields[I]~";"); } auto opDispatch(string __s__)(){//I suggest a habit of avoiding simple names when generating

Re: Debug help - opDispatch - unknown member function

2025-09-09 Thread Dejan Lekic via Digitalmars-d-learn
r." So I tried that. But the compiler didn't like it. How should I play the game of passing in an unknown member function name? Hopefully this slightly modified, and commented version of your original code will help you understand why your mixin is failing: ```d import s

Re: Debug help - opDispatch - unknown member function

2025-09-08 Thread monkyyy via Digitalmars-d-learn
On Tuesday, 9 September 2025 at 01:08:41 UTC, Brother Bill wrote: On Tuesday, 9 September 2025 at 00:45:00 UTC, monkyyy wrote: On Tuesday, 9 September 2025 at 00:40:31 UTC, Brother Bill wrote: https://tour.dlang.org/tour/en/gems/opdispatch-opapply This states: "Any unknown member function call

Re: Debug help - delegate from dlang Tour

2025-09-08 Thread Steven Schveighoffer via Digitalmars-d-learn
On Monday, 8 September 2025 at 16:23:23 UTC, Brother Bill wrote: On Monday, 8 September 2025 at 14:42:01 UTC, evilrat wrote: probably because you have declared nested function `add` inside `main`, this creates a delegate closure capturing `main` scope, if you don't want that just mark `add` s

Re: Debug help - delegate from dlang Tour

2025-09-08 Thread Brother Bill via Digitalmars-d-learn
On Monday, 8 September 2025 at 14:42:01 UTC, evilrat wrote: probably because you have declared nested function `add` inside `main`, this creates a delegate closure capturing `main` scope, if you don't want that just mark `add` static. Yep, as a nested function, this is a delegate, not a func

Re: Debug help - delegate from dlang Tour

2025-09-08 Thread Brother Bill via Digitalmars-d-learn
It works by making doSomething as a delegate.

Re: Debug help - delegate from dlang Tour

2025-09-08 Thread Brother Bill via Digitalmars-d-learn
On Monday, 8 September 2025 at 14:42:01 UTC, evilrat wrote: probably because you have declared nested function `add` inside `main`, this creates a delegate closure capturing `main` scope, if you don't want that just mark `add` static. Marking add static works. Still don't understand why thi

Debug help - delegate from dlang Tour

2025-09-08 Thread Brother Bill via Digitalmars-d-learn
https://tour.dlang.org/tour/en/basics/delegates This is so simple. What is D complaining about? Should this also work with a Template, as shown? ``` import std.stdio; void main() { // auto add(T)(T lhs, T rhs) // { // return lhs + rhs; // } int add

Re: Debug help - Programming in D exercise 3 on page 352. AA and opCmp

2025-09-07 Thread Dejan Lekic via Digitalmars-d-learn
On Sunday, 7 September 2025 at 12:53:58 UTC, Brother Bill wrote: Two assert statements on lines 43 and 44 fail. Should these assert statements be correct, and if so, what changes to make them correct. Or are they incorrect, and should be removed? Or have I made a mistake in implementing this e

Debug help - Programming in D exercise 3 on page 352. AA and opCmp

2025-09-07 Thread Brother Bill via Digitalmars-d-learn
Two assert statements on lines 43 and 44 fail. Should these assert statements be correct, and if so, what changes to make them correct. Or are they incorrect, and should be removed? Or have I made a mistake in implementing this exercise solution? Console output ``` areas:[TriangularArea (1, 2)

Re: Debug help - Programming in D, page 670 allocate buffer of 10 MyClass class instances

2025-09-03 Thread Ali Çehreli via Digitalmars-d-learn
On 9/3/25 5:10 AM, Brother Bill wrote: > Made some further changes, and have additional questions. One of your question involves object aligment, which I mention here: https://ddili.org/ders/d.en/memory.html#ix_memory..alignof I discovered two (somewhat cryptic) functions there that computes

Re: Debug help - Programming in D, page 670 allocate buffer of 10 MyClass class instances

2025-09-03 Thread Brother Bill via Digitalmars-d-learn
On Wednesday, 3 September 2025 at 03:09:45 UTC, Ali Çehreli wrote: GC.calloc(bytesNeeded); Again, I misled you there. > writeln("myClasses address: ", myClasses); > > alias MyClassPtr = MyClass *; That's not useful because the type MyClass is already a reference type, implemented as

Re: Debug help - Programming in D, page 670 allocate buffer of 10 MyClass class instances

2025-09-02 Thread Ali Çehreli via Digitalmars-d-learn
On 9/2/25 4:51 PM, Brother Bill wrote: > The code snippet from the book is: > ``` > // Allocate room for 10 MyClass objects > MyClass * buffer = > cast(MyClass*)GC.calloc( > __traits(classInstanceSize, MyClass) * 10); > ``` For clarity, we are talking about this page: https

Debug help - Programming in D, page 670 allocate buffer of 10 MyClass class instances

2025-09-02 Thread Brother Bill via Digitalmars-d-learn
The code snippet from the book is: ``` // Allocate room for 10 MyClass objects MyClass * buffer = cast(MyClass*)GC.calloc( __traits(classInstanceSize, MyClass) * 10); ``` ``` class MyClass { int a; string name; char c; } ``` MyClass is defined as a simple

Re: Debug help - Ranges - Programming in D page 598

2025-09-01 Thread Steven Schveighoffer via Digitalmars-d-learn
On Friday, 29 August 2025 at 01:51:27 UTC, Steven Schveighoffer wrote: On Friday, 29 August 2025 at 01:24:40 UTC, Steven Schveighoffer wrote: Will file an issue, and we should get this fixed. https://github.com/dlang/phobos/issues/10852 Fixed! https://github.com/dlang/phobos/pull/10854 Wi

Re: Debug help - ! in data sharing concurrency

2025-08-31 Thread Andy Valencia via Digitalmars-d-learn
On Sunday, 31 August 2025 at 22:53:51 UTC, Steven Schveighoffer wrote: `std.concurrency` is meant to make all these control flow systems easy to avoid races for, even in `@safe` code. Sending the boolean instead of keeping a pointer to a shared boolean can alleviate a lot of these problems.

Re: Debug help - ! in data sharing concurrency

2025-08-31 Thread Steven Schveighoffer via Digitalmars-d-learn
On Sunday, 31 August 2025 at 12:44:33 UTC, Brother Bill wrote: On Sunday, 31 August 2025 at 01:27:57 UTC, Steven Schveighoffer wrote: Why would your second iteration make a difference? Purely by chance! In fact, on my machine, it does not exit in either case. Welcome to the wonderful world of

Re: Debug help - ! in data sharing concurrency

2025-08-31 Thread Andy Valencia via Digitalmars-d-learn
On Sunday, 31 August 2025 at 12:44:33 UTC, Brother Bill wrote: FWIW, given that D supports Message Passing Concurrency, is Data Sharing Concurrency just there for D completeness, for those that want to live close to the iron. Speaking as a guy who did Unix kernel SMP for years, there are time

Re: Debug help - ! in data sharing concurrency

2025-08-31 Thread Brother Bill via Digitalmars-d-learn
On Sunday, 31 August 2025 at 01:27:57 UTC, Steven Schveighoffer wrote: Why would your second iteration make a difference? Purely by chance! In fact, on my machine, it does not exit in either case. Welcome to the wonderful world of race conditions and multithreading! So this was just 'bad' lu

Re: Debug help - ! in data sharing concurrency

2025-08-30 Thread Steven Schveighoffer via Digitalmars-d-learn
On Saturday, 30 August 2025 at 22:05:49 UTC, Brother Bill wrote: A predicate (!*isDone) vs. (*isDone == false) seems to have different behavior, where I would expect identical behavior. What am I missing? This program runs forever, even though isDone changes from false to true. ```d import

Debug help - ! in data sharing concurrency

2025-08-30 Thread Brother Bill via Digitalmars-d-learn
A predicate (!*isDone) vs. (*isDone == false) seems to have different behavior, where I would expect identical behavior. What am I missing? This program runs forever, even though isDone changes from false to true. ``` import std.stdio; import std.concurrency; import core.thread; import core.

Re: Debug help - Programming in D page 633 - concurrency shared(Exception) warnings

2025-08-30 Thread Brother Bill via Digitalmars-d-learn
On Saturday, 30 August 2025 at 18:04:20 UTC, Steven Schveighoffer wrote: On Saturday, 30 August 2025 at 11:43:27 UTC, Brother Bill wrote: I tried various code changes, none of which worked. Kindly provide code changes to fix warnings that reflect modern D programming. This worked for me: W

Re: Debug help - Programming in D page 633 - concurrency shared(Exception) warnings

2025-08-30 Thread Steven Schveighoffer via Digitalmars-d-learn
On Saturday, 30 August 2025 at 11:43:27 UTC, Brother Bill wrote: I tried various code changes, none of which worked. Kindly provide code changes to fix warnings that reflect modern D programming. This worked for me: ```d import std.stdio; import std.concurrency; import std.conv; struct Calc

Re: Debug help - Programming in D page 633 - concurrency shared(Exception) warnings

2025-08-30 Thread Brother Bill via Digitalmars-d-learn
On Saturday, 30 August 2025 at 03:21:14 UTC, Steven Schveighoffer wrote: `Tid` can only send or receive shared or immutable data. This is a long standing requirement, and it makes sense. The thing is, this data is shared *only* when it is going through the message system. Once it's out, you ca

Re: Debug help - Programming in D page 633 - concurrency shared(Exception) warnings

2025-08-29 Thread Steven Schveighoffer via Digitalmars-d-learn
A note on your references here: I'm assuming you are working from a physical book. But the online book is here: https://ddili.org/ders/d.en/index.html When you have questions, if you could link to the content, that would be really helpful. Especially since you are not including the entire ma

Debug help - Programming in D page 633 - concurrency shared(Exception) warnings

2025-08-29 Thread Brother Bill via Digitalmars-d-learn
If this technique is still valid, I need the code modernized so that it works without warnings. I'm still in the D learning curve, so I don't quite know what is being warned, and how to clean up the mess. I believe that the new code runs properly, but it would be nice for it to be 'warning f

Re: Debug help - Ranges - Programming in D page 598

2025-08-28 Thread Steven Schveighoffer via Digitalmars-d-learn
On Friday, 29 August 2025 at 01:24:40 UTC, Steven Schveighoffer wrote: Will file an issue, and we should get this fixed. https://github.com/dlang/phobos/issues/10852 -Steve

Re: Debug help - Ranges - Programming in D page 598

2025-08-28 Thread Steven Schveighoffer via Digitalmars-d-learn
On Thursday, 28 August 2025 at 11:54:10 UTC, Brother Bill wrote: If line 9 of the program is commented out, it runs fine. Otherwise lots of error messages which don't pan out for me. I tried changing Negative.front to be const, which didn't help. I am not quite sure what the error me

Re: Debug help - static foreach - module scope - Programming in D page 603

2025-08-28 Thread Sergey via Digitalmars-d-learn
On Thursday, 28 August 2025 at 13:33:09 UTC, Brother Bill wrote: On Thursday, 28 August 2025 at 13:16:26 UTC, Andy Valencia wrote: Output to console: Why does static foreach run 'twice'? run.dlang.org run only once

Re: Debug help - static foreach - module scope - Programming in D page 603

2025-08-28 Thread Brother Bill via Digitalmars-d-learn
On Thursday, 28 August 2025 at 13:16:26 UTC, Andy Valencia wrote: On Thursday, 28 August 2025 at 13:09:21 UTC, Brother Bill wrote: Unable to compile. Please advise. ``` c:\dev\D\81 - 90\c83_e_static_foreach_fibonacci\source\app.d(8): Error: function declaration without return type. (Note that

Re: Debug help - Ranges - Programming in D page 598

2025-08-28 Thread monkyyy via Digitalmars-d-learn
On Thursday, 28 August 2025 at 15:21:41 UTC, Andy Valencia wrote: On Thursday, 28 August 2025 at 14:15:54 UTC, monkyyy wrote: They lose the plot and you have to sometimes offer your own solutions, its often not worth debugging, if you see an ugly phoboes error on what should be a simple range

Re: Debug help - Ranges - Programming in D page 598

2025-08-28 Thread Andy Valencia via Digitalmars-d-learn
On Thursday, 28 August 2025 at 14:15:54 UTC, monkyyy wrote: They lose the plot and you have to sometimes offer your own solutions, its often not worth debugging, if you see an ugly phoboes error on what should be a simple range concept, consider not even looking. Although at least consider s

Re: Debug help - Ranges - Programming in D page 598

2025-08-28 Thread monkyyy via Digitalmars-d-learn
On Thursday, 28 August 2025 at 11:54:10 UTC, Brother Bill wrote: If line 9 of the program is commented out, it runs fine. Otherwise lots of error messages which don't pan out for me. I tried changing Negative.front to be const, which didn't help. I am not quite sure what the error me

Re: Debug help - static foreach - module scope - Programming in D page 603

2025-08-28 Thread Andy Valencia via Digitalmars-d-learn
On Thursday, 28 August 2025 at 13:09:21 UTC, Brother Bill wrote: Unable to compile. Please advise. ``` c:\dev\D\81 - 90\c83_e_static_foreach_fibonacci\source\app.d(8): Error: function declaration without return type. (Note that constructors are always named `this`) writeln(n); writeln(

Debug help - static foreach - module scope - Programming in D page 603

2025-08-28 Thread Brother Bill via Digitalmars-d-learn
Unable to compile. Please advise. ``` c:\dev\D\81 - 90\c83_e_static_foreach_fibonacci\source\app.d(8): Error: function declaration without return type. (Note that constructors are always named `this`) writeln(n); ^ c:\dev\D\81 - 90\c83_e_static_foreach_fibonacci\source\app.d(8):

Debug help - Ranges - Programming in D page 598

2025-08-28 Thread Brother Bill via Digitalmars-d-learn
If line 9 of the program is commented out, it runs fine. Otherwise lots of error messages which don't pan out for me. I tried changing Negative.front to be const, which didn't help. I am not quite sure what the error messages are telling me. Thank you for your assistance! ``` C:\D\dm

Re: Debug help - foreach opApply overload School example: Programming in D

2025-08-18 Thread Brother Bill via Digitalmars-d-learn
On Monday, 18 August 2025 at 17:58:54 UTC, Dejan Lekic wrote: So, to fix your error, you can remove the "const" method qualifier from opApply, or cast the const away from the member when you use it. Thanks for the tip. It just needed more 'const' keywords sprinkled in here and there. Here

Re: Debug help - foreach opApply overload School example: Programming in D

2025-08-18 Thread Dejan Lekic via Digitalmars-d-learn
On Monday, 18 August 2025 at 13:32:57 UTC, Brother Bill wrote: Page 496 of Programming in D Going in circles. Please correct so it compiles and works. An explanation would be helpful also. Ali's book have a section about const member qualifier - "51.5 const member functions", but I think it

Debug help - foreach opApply overload School example: Programming in D

2025-08-18 Thread Brother Bill via Digitalmars-d-learn
Page 496 of Programming in D Going in circles. Please correct so it compiles and works. An explanation would be helpful also. Error Message ``` c:\dev\D\71 - 80\c73_2d_School_Student_Teacher\source\app.d(23): Error: cannot implicitly convert expression `this.students[cast(ulong)i]` of type `c

Enhancing Learning Through Personalized Academic Help

2025-06-12 Thread Ying Ashley via Digitalmars-d-learn
demands in their academic journey, finding ways to make learning more efficient and meaningful becomes essential. One effective way to improve academic learning is through [essay help](https://myassignmenthelp.expert/essay-help/). Crafting a compelling essay requires more than just writing skills

Re: getopt usage help to stderr?

2025-05-12 Thread Justin Allen Parrott via Digitalmars-d-learn
it|e", "Exit process", &test, "verbose|v", "Enable verbose output", &verbose ); if (rslt.helpWanted) { // Capture help text to a string import std.array : appender; import std.format

Re: getopt usage help to stderr?

2025-04-10 Thread kdevel via Digitalmars-d-learn
h, -e, -l, and -v in that order: -h prints what one expects. If help is wanted I expect the usage info be written on stdout though. Nothing bothers more than programs with multiple pages of usage help written you cannot pipe cleanly to less. -e says "-h --help This help information&quo

Re: getopt usage help to stderr?

2025-04-08 Thread Andy Valencia via Digitalmars-d-learn
h, -e, -l, and -v in that order: ... Thank you. It turned out, aside from treating stderr with lockingTextWriter, I had a couple "in" arguments, which defaultGetoptFormatter wouldn't accept. So with all that cleared up, help is now available. Thank you again (both of

Re: getopt usage help to stderr?

2025-04-08 Thread Salih Dincer via Digitalmars-d-learn
erbose|v", "Enable verbose output", &verbose ); if (rslt.helpWanted) { // Capture help text to a string import std.array : appender; import std.format : formattedWrite; auto helpText = appender!string();

Re: getopt usage help to stderr?

2025-04-08 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
I think that you are almost there. https://dlang.org/phobos/std_getopt.html#.defaultGetoptFormatter Try using: https://dlang.org/phobos/std_stdio.html#.File.lockingTextWriter ``defaultGetoptFormatter(stderr.lockingTextWriter, "heading", helpInformation.options);``

getopt usage help to stderr?

2025-04-08 Thread Andy Valencia via Digitalmars-d-learn
This seems like something which needs to be straightforward, and yet I've spent a good amount of time getting nowhere. How does one get the usage information which getopt embeds in a result, and spit it out to stderr? The internals show some help output, hard-coded to stdout. As any

Re: help with prime pairs code

2025-02-21 Thread Salih Dincer via Digitalmars-d-learn
On Wednesday, 19 February 2025 at 23:58:09 UTC, Salih Dincer wrote: On Friday, 31 January 2025 at 20:05:54 UTC, Jabari Zakiya wrote: I'm converting Ruby code to D and am running into issues. Would appreciate what needs to be done to get it to compile/run correctly. I removed 1 line in your co

Re: help with prime pairs code

2025-02-19 Thread Salih Dincer via Digitalmars-d-learn
On Friday, 31 January 2025 at 20:05:54 UTC, Jabari Zakiya wrote: I'm converting Ruby code to D and am running into issues. Would appreciate what needs to be done to get it to compile/run correctly. First of all, I see that you don't use reserve() at all in arrays. Since I work on a mobile pla

Re: help with prime pairs code

2025-02-19 Thread Sergey via Digitalmars-d-learn
On Wednesday, 19 February 2025 at 02:25:03 UTC, Salih Dincer wrote: have much time right now, I only saw 1 improvement. Below the GCD filter will give the same list (lhr[]). SDB@79 It is giving different result

Re: help with prime pairs code

2025-02-18 Thread monkyyy via Digitalmars-d-learn
On Tuesday, 18 February 2025 at 22:45:39 UTC, Jabari Zakiya wrote: I'm bringing attention to this issue as it might improve D. Known issue with upstream, try one of mine data structures https://github.com/opendlang/d/blob/main/source/odc/datastructures.d

Re: help with prime pairs code

2025-02-18 Thread Jabari Zakiya via Digitalmars-d-learn
// convert lhr_mults vals > n/2 to their lhr complements n-r, // store them, those < n/2, in lhr_del; it now holds non-pcp lhr vals auto lhr_del = lhr_mults.map!((r_del) => r_del > ndiv2 ? n - r_del : r_del).array; lhr_del.sort!("a < b"); lhr = setDifference(lhr, l

Re: help with prime pairs code

2025-02-08 Thread Jabari Zakiya via Digitalmars-d-learn
On Wednesday, 5 February 2025 at 21:24:51 UTC, Jabari Zakiya wrote: On Tuesday, 4 February 2025 at 17:17:42 UTC, Jabari Zakiya wrote: On Monday, 3 February 2025 at 04:59:43 UTC, monkyyy wrote: On Monday, 3 February 2025 at 04:15:09 UTC, Jabari Zakiya wrote: I translated this Ruby code: FY

Re: help with prime pairs code

2025-02-05 Thread Jabari Zakiya via Digitalmars-d-learn
On Tuesday, 4 February 2025 at 17:17:42 UTC, Jabari Zakiya wrote: On Monday, 3 February 2025 at 04:59:43 UTC, monkyyy wrote: On Monday, 3 February 2025 at 04:15:09 UTC, Jabari Zakiya wrote: I translated this Ruby code: FYI. This code finds all the prime pairs that sum to n for all even in

Re: help with prime pairs code

2025-02-04 Thread Jabari Zakiya via Digitalmars-d-learn
On Monday, 3 February 2025 at 04:59:43 UTC, monkyyy wrote: On Monday, 3 February 2025 at 04:15:09 UTC, Jabari Zakiya wrote: I translated this Ruby code: FYI. This code finds all the prime pairs that sum to n for all even integers n > 2. It (Ruby code) is included in a paper I just released

Re: help with prime pairs code

2025-02-02 Thread monkyyy via Digitalmars-d-learn
On Monday, 3 February 2025 at 04:15:09 UTC, Jabari Zakiya wrote: I translated this Ruby code: To this D code. It works, seems fast, can it be done shorter, faster, more idiomatic? translated code isnt going to be idiomatic ever; just state what you want done

Re: help with prime pairs code

2025-02-02 Thread Sergey via Digitalmars-d-learn
On Sunday, 2 February 2025 at 22:40:41 UTC, Jabari Zakiya wrote: I am really impressed! D is phenomenally memory efficient with this code. I just ran the D code for some really large n values. On my older Lenovo Legion 5, using Linux (June 2024) w/16GB I was able to go up to n = 1,000,000, a

Re: help with prime pairs code

2025-02-02 Thread Sergey via Digitalmars-d-learn
On Sunday, 2 February 2025 at 03:22:00 UTC, Jabari Zakiya wrote: The D version is way slower, because of the array operations. For an input of 100 (1M): D: 12+ secs; Crystal: 0.036 secs. First of fall make sure you are using LDC or GDC compiler. Second step is to add proper flags for optim

Re: help with prime pairs code

2025-02-01 Thread Jabari Zakiya via Digitalmars-d-learn
On Sunday, 2 February 2025 at 01:39:34 UTC, user1234 wrote: On Sunday, 2 February 2025 at 01:12:59 UTC, user1234 wrote: On Saturday, 1 February 2025 at 21:56:23 UTC, Jabari Zakiya wrote: On Saturday, 1 February 2025 at 00:21:22 UTC, user1234 wrote: On Friday, 31 January 2025 at 20:05:54 UTC, Ja

Re: help with prime pairs code

2025-02-01 Thread user1234 via Digitalmars-d-learn
On Sunday, 2 February 2025 at 01:12:59 UTC, user1234 wrote: On Saturday, 1 February 2025 at 21:56:23 UTC, Jabari Zakiya wrote: On Saturday, 1 February 2025 at 00:21:22 UTC, user1234 wrote: On Friday, 31 January 2025 at 20:05:54 UTC, Jabari Zakiya wrote: [...] A first draft of the translation

Re: help with prime pairs code

2025-02-01 Thread user1234 via Digitalmars-d-learn
On Saturday, 1 February 2025 at 21:56:23 UTC, Jabari Zakiya wrote: On Saturday, 1 February 2025 at 00:21:22 UTC, user1234 wrote: On Friday, 31 January 2025 at 20:05:54 UTC, Jabari Zakiya wrote: [...] A first draft of the translation, not very idiomatic D code: ```d module prime_pairs; import

Re: help with prime pairs code

2025-02-01 Thread Jabari Zakiya via Digitalmars-d-learn
On Saturday, 1 February 2025 at 00:21:22 UTC, user1234 wrote: On Friday, 31 January 2025 at 20:05:54 UTC, Jabari Zakiya wrote: [...] A first draft of the translation, not very idiomatic D code: ```d module prime_pairs; import std; [...] Thank you very much! As you can see, D is not my pri

Re: help with prime pairs code

2025-01-31 Thread user1234 via Digitalmars-d-learn
On Friday, 31 January 2025 at 20:05:54 UTC, Jabari Zakiya wrote: I'm converting Ruby code to D and am running into issues. Would appreciate what needs to be done to get it to compile/run correctly. Here's the Ruby code: [...] A first draft of the translation, not very idiomatic D code: ```

help with prime pairs code

2025-01-31 Thread Jabari Zakiya via Digitalmars-d-learn
I'm converting Ruby code to D and am running into issues. Would appreciate what needs to be done to get it to compile/run correctly. Here's the Ruby code: ``` # Enable YJIT if using CRuby >= 3.3" RubyVM::YJIT.enable if RUBY_ENGINE == "ruby" and RUBY_VERSION.to_f >= 3.3 def prime_pairs_lohi(

Re: All things noobs need help with

2025-01-19 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
On 20/01/2025 9:08 AM, Mad - Ram wrote: Hi how do i add my picture to the dlang website to see a pic like all the other people in the forums https://forum.dlang.org/help Avatars The forum will display avatars associated with users' email addresses. If the email address is registered

All things noobs need help with

2025-01-19 Thread Mad - Ram via Digitalmars-d-learn
Hi how do i add my picture to the dlang website to see a pic like all the other people in the forums

Re: Would appreciate some help porting Q3VM to D (mainly C macros and type conversions)

2024-10-18 Thread matheus via Digitalmars-d-learn
On Friday, 18 October 2024 at 14:41:15 UTC, Mark Bauermeister wrote: ...No more segfaults thus far but strangely the proper switch case... One thing that I can think looking at your code: import std.stdio; void main(){ int op = 1; switch(op){ default: writeln("default"); retur

Re: Would appreciate some help porting Q3VM to D (mainly C macros and type conversions)

2024-10-18 Thread Jordan Wilson via Digitalmars-d-learn
On Friday, 18 October 2024 at 14:41:15 UTC, Mark Bauermeister wrote: On Thursday, 17 October 2024 at 02:47:03 UTC, Mai Lapyst wrote: [...] Yea. I forgot about the sizeof division being wrong. I replaced all calls to ARRAY_LEN with \.length. [...] Is the `switch` correct? I would expect to

Re: Would appreciate some help porting Q3VM to D (mainly C macros and type conversions)

2024-10-18 Thread Mark Bauermeister via Digitalmars-d-learn
On Thursday, 17 October 2024 at 02:47:03 UTC, Mai Lapyst wrote: On Wednesday, 16 October 2024 at 13:10:34 UTC, Mark Bauermeister wrote: I think I got every compiler complaint fixed now. However, upon launch the program immediately quits with "Error Program exited with code -11". I assume that's

Re: need help to find a way to replace c macro

2024-10-17 Thread Dakota via Digitalmars-d-learn
On Tuesday, 15 October 2024 at 15:29:09 UTC, ryuukk_ wrote: [...] Thanks very much.

Re: Would appreciate some help porting Q3VM to D (mainly C macros and type conversions)

2024-10-16 Thread Mai Lapyst via Digitalmars-d-learn
On Wednesday, 16 October 2024 at 13:10:34 UTC, Mark Bauermeister wrote: I think I got every compiler complaint fixed now. However, upon launch the program immediately quits with "Error Program exited with code -11". I assume that's a segfault, right? https://gist.github.com/markusbkk/442a57135

Re: Would appreciate some help porting Q3VM to D (mainly C macros and type conversions)

2024-10-16 Thread Mark Bauermeister via Digitalmars-d-learn
more macros. Now if only I could figure out how to resolve "variable `codeImage` cannot be read at compile time". That's the last thing neither of those automation solutions can help me with. if you mean line 966 you need to replace `enum` by `const` or even `auto`. `enum`

Re: Would appreciate some help porting Q3VM to D (mainly C macros and type conversions)

2024-10-16 Thread Mark Bauermeister via Digitalmars-d-learn
iable `codeImage` cannot be read at compile time". That's the last thing neither of those automation solutions can help me with. if you mean line 966 you need to replace `enum` by `const` or even `auto`. `enum` means the value should be available in compile time. Ah! Makes sense.

Re: Would appreciate some help porting Q3VM to D (mainly C macros and type conversions)

2024-10-15 Thread drug007 via Digitalmars-d-learn
age` cannot be read at compile time". That's the last thing neither of those automation solutions can help me with. if you mean line 966 you need to replace `enum` by `const` or even `auto`. `enum` means the value should be available in compile time.

Re: Would appreciate some help porting Q3VM to D (mainly C macros and type conversions)

2024-10-15 Thread Mark Bauermeister via Digitalmars-d-learn
ot;. That's the last thing neither of those automation solutions can help me with.

Re: Would appreciate some help porting Q3VM to D (mainly C macros and type conversions)

2024-10-15 Thread Lance Bachmeier via Digitalmars-d-learn
On Tuesday, 15 October 2024 at 13:30:03 UTC, Mark Bauermeister wrote: On Tuesday, 15 October 2024 at 12:27:42 UTC, barbosso wrote: Are you heard of https://github.com/dkorpel/ctod ? I actually used CTOD for part of the translation but it wouldn't translate the macros correctly. It turned them

Re: need help to find a way to replace c macro

2024-10-15 Thread ryuukk_ via Digitalmars-d-learn
Try this great tool by denis korpel https://dkorpel.github.io/ctod/ I've been using it every so often to port C stuff, it's been very helpful ```D @nogc nothrow: extern(C): __gshared: union JSCFunctionType { JSCFunction* generic; JSValue function(JSContext* ctx, JSValueConst this_val,

Re: Would appreciate some help porting Q3VM to D (mainly C macros and type conversions)

2024-10-15 Thread Mark Bauermeister via Digitalmars-d-learn
On Tuesday, 15 October 2024 at 12:27:42 UTC, barbosso wrote: Are you heard of https://github.com/dkorpel/ctod ? I actually used CTOD for part of the translation but it wouldn't translate the macros correctly. It turned them into weird string mixins.

Re: need help to find a way to replace c macro

2024-10-15 Thread Dakota via Digitalmars-d-learn
On Tuesday, 15 October 2024 at 12:13:36 UTC, monkyyy wrote: Your probably going to need to simplify that block of code looks awful source code here: https://github.com/bellard/quickjs/blob/master/quickjs.h#L1045

Re: Would appreciate some help porting Q3VM to D (mainly C macros and type conversions)

2024-10-15 Thread barbosso via Digitalmars-d-learn
Are you heard of https://github.com/dkorpel/ctod ?

Re: need help to find a way to replace c macro

2024-10-15 Thread monkyyy via Digitalmars-d-learn
On Tuesday, 15 October 2024 at 12:05:16 UTC, Dakota wrote: ```c typedef union JSCFunctionType { JSCFunction *generic; JSValue (*generic_magic)(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv, int magic); JSCFunction *constructor; JSValue (*constructor_magic)(

need help to find a way to replace c macro

2024-10-15 Thread Dakota via Digitalmars-d-learn
```c typedef union JSCFunctionType { JSCFunction *generic; JSValue (*generic_magic)(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv, int magic); JSCFunction *constructor; JSValue (*constructor_magic)(JSContext *ctx, JSValueConst new_target, int argc, JSValueC

Would appreciate some help porting Q3VM to D (mainly C macros and type conversions)

2024-10-15 Thread Mark Bauermeister via Digitalmars-d-learn
nd here: https://gist.github.com/markusbkk/442a571353a48c5377c503e7d02570fb My main problem are the macro functions at line 398 in my code, as well as the compiler telling me that "static variable `codeImage` cannot be read at compile time". Would really appreciate some help with this from the D Lords of this group.

Re: need help to redefine packed c struct in d

2024-09-28 Thread Dakota via Digitalmars-d-learn
On Saturday, 28 September 2024 at 08:35:39 UTC, Johan wrote: On Saturday, 28 September 2024 at 07:54:40 UTC, Dakota wrote: ```c struct __attribute__((packed)) type1 { uint32_tu32; uint8_t u8; uint16_tu16a; uint16_tu16b; uint8_t u8a;

Re: need help to redefine packed c struct in d

2024-09-28 Thread Johan via Digitalmars-d-learn
On Saturday, 28 September 2024 at 07:54:40 UTC, Dakota wrote: ```c struct __attribute__((packed)) type1 { uint32_tu32; uint8_t u8; uint16_tu16a; uint16_tu16b; uint8_t u8a; uint8_t arr[14]; }; ``` the struct size in C is 24:

Re: need help to work around float union non-zero init

2024-09-23 Thread Dakota via Digitalmars-d-learn
On Friday, 20 September 2024 at 16:21:10 UTC, Nick Treleaven wrote: On Friday, 20 September 2024 at 09:38:54 UTC, Dakota wrote: Thanks to Dennis for the workaround. Thanks your all for the tips, void solution fix me problem.

Re: need help to work around float union non-zero init

2024-09-20 Thread Nick Treleaven via Digitalmars-d-learn
On Friday, 20 September 2024 at 09:38:54 UTC, Dakota wrote: I need my struct defined as `isZeroInit`, so can I can import them as `di` file. (this also reduce build size) But I find this problem with float inside union: ```d struct test_t { union { int i32; float f32;

Re: need help to work around float union non-zero init

2024-09-20 Thread monkyyy via Digitalmars-d-learn
On Friday, 20 September 2024 at 09:38:54 UTC, Dakota wrote: I need my struct defined as `isZeroInit`, so can I can import them as `di` file. (this also reduce build size) But I find this problem with float inside union: ```d struct test_t { union { int i32; float f32;

Re: need help to work around float union non-zero init

2024-09-20 Thread IchorDev via Digitalmars-d-learn
On Friday, 20 September 2024 at 09:38:54 UTC, Dakota wrote: I consider this is compiler bug (it may take years to get fixed) I've sent issues for compiler bugs and had them fixed within the next release—about month, not years. Also yes, this seems to be a compiler bug; unless there's some s

need help to work around float union non-zero init

2024-09-20 Thread Dakota via Digitalmars-d-learn
I need my struct defined as `isZeroInit`, so can I can import them as `di` file. (this also reduce build size) But I find this problem with float inside union: ```d struct test_t { union { int i32; float f32; } } static assert(__traits(isZeroInit, test_t) ); ``` ``

Re: need help to use Emscripten with LDC to build wasm projects

2024-08-23 Thread monkyyy via Digitalmars-d-learn
On Friday, 23 August 2024 at 05:50:43 UTC, Dakota wrote: any suggestions how to fix this? ```sh /ldc/bin/../import/core/stdc/stdio.d(31): Error: module ``` I dont use the std with wasm, everything imports everything else and there are just broken symbols deep in "core" that wont be fixed

Re: need help to use Emscripten with LDC to build wasm projects

2024-08-22 Thread Dakota via Digitalmars-d-learn
On Thursday, 22 August 2024 at 21:19:57 UTC, monkyyy wrote: On Thursday, 22 August 2024 at 07:28:00 UTC, Dakota wrote: Is there a way to link ldc objects with Emscripten to build wasm binary ? yes; you'll have to untangle my build system https://github.com/crazymonkyyy/raylib-2024 It will al

Re: need help to use Emscripten with LDC to build wasm projects

2024-08-22 Thread monkyyy via Digitalmars-d-learn
On Thursday, 22 August 2024 at 07:28:00 UTC, Dakota wrote: Is there a way to link ldc objects with Emscripten to build wasm binary ? yes; you'll have to untangle my build system https://github.com/crazymonkyyy/raylib-2024 It will always suck tho

Re: need help to use Emscripten with LDC to build wasm projects

2024-08-22 Thread Ferhat Kurtulmuş via Digitalmars-d-learn
On Thursday, 22 August 2024 at 07:28:00 UTC, Dakota wrote: Is there a way to link ldc objects with Emscripten to build wasm binary ? Some years a go, i was able to build and run my hobby game using EMScripen. Things must be changed now. I drop the link here. I cannot help further since i

Re: need help to check symbol is static variable or not

2024-07-15 Thread Dakota via Digitalmars-d-learn
On Monday, 15 July 2024 at 11:16:23 UTC, Nick Treleaven wrote: I put `type_s` in a file anonstruct.c, then: ```d import anonstruct; pragma(msg, isStatic!(type_s.c)); ``` That outputs `false`, because the symbol is not a compile-time value. Is that what you meant? No, I am here deal with a lo

  1   2   3   4   5   6   7   8   9   10   >