Unexpected behaviour in associative array

2019-04-19 Thread Arredondo via Digitalmars-d-learn
Hi all, I'm using a custom Struct as the key type in an associative array. I have defined the toHash() and opEquals(...) functions, and the problem I'm having is that the test mykey in aa always fails (returns null) even though there are keys in the aa that return identical toHash() values

Re: Convert array to custom type when passing function argument

2019-04-19 Thread Ali Çehreli via Digitalmars-d-learn
On 04/17/2019 05:21 PM, Stefanos Baziotis wrote: > On Wednesday, 17 April 2019 at 23:44:42 UTC, Adam D. Ruppe wrote: >>explicit Test(const char* foo) {} // this opts out of the cool >> thing above > Actually, I asked initially because in C++ you can do the thing I > described. > I thought

Re: Unexpected behaviour in associative array

2019-04-19 Thread Andre Pany via Digitalmars-d-learn
On Friday, 19 April 2019 at 11:10:16 UTC, Arredondo wrote: Hi all, I'm using a custom Struct as the key type in an associative array. I have defined the toHash() and opEquals(...) functions, and the problem I'm having is that the test mykey in aa always fails (returns null) even though

Re: Unexpected behaviour in associative array

2019-04-19 Thread Andre Pany via Digitalmars-d-learn
On Friday, 19 April 2019 at 11:53:37 UTC, Andre Pany wrote: On Friday, 19 April 2019 at 11:41:53 UTC, Arredondo wrote: On Friday, 19 April 2019 at 11:32:17 UTC, Andre Pany wrote: Could you please post the coding, otherwise it is quite hard to help you. Kind regards Andre Yes, I'm working

Re: Unexpected behaviour in associative array

2019-04-19 Thread Arredondo via Digitalmars-d-learn
On Friday, 19 April 2019 at 11:32:17 UTC, Andre Pany wrote: Could you please post the coding, otherwise it is quite hard to help you. Here's a reasonably-sized code fragment that demonstrates the issue. I hope the comments along the way are descriptive enough Thanks, Arredondo --

Re: Unexpected behaviour in associative array

2019-04-19 Thread Andre Pany via Digitalmars-d-learn
On Friday, 19 April 2019 at 11:41:53 UTC, Arredondo wrote: On Friday, 19 April 2019 at 11:32:17 UTC, Andre Pany wrote: Could you please post the coding, otherwise it is quite hard to help you. Kind regards Andre Yes, I'm working on isolating the problem. It's a bit laborious because the

Re: Unexpected behaviour in associative array

2019-04-19 Thread Arredondo via Digitalmars-d-learn
On Friday, 19 April 2019 at 11:55:41 UTC, Andre Pany wrote: https://dub.pm/commandline.html#dustmite Thanks, but it appears that this tool is used to isolate the cause of build errors, and I'm not having build errors, just unexpected behavior at runtime. Something I have observed while

gtkDcoding Blog Post # 28 - Menu II - CheckMenuItem

2019-04-19 Thread Ron Tarrant via Digitalmars-d-learn
Even though it's Good Friday, there's still a new blog post. As the thread title says, it's about using the CheckMenuItem, two examples this time. You can find it here: http://gtkdcoding.com/2019/04/19/0028-checkmenuitems.html Have a great long weekend, everyone!

Re: Unexpected behaviour in associative array

2019-04-19 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 19 April 2019 at 12:03:33 UTC, Arredondo wrote: key in aa Keep in mind that D's `in` operator returns a *pointer* to the element, or null if it isn't there. If you aren't treating the return value as a pointer, you could hit trouble.

Re: Unexpected behaviour in associative array

2019-04-19 Thread Arredondo via Digitalmars-d-learn
On Friday, 19 April 2019 at 12:43:06 UTC, Adam D. Ruppe wrote: On Friday, 19 April 2019 at 12:03:33 UTC, Arredondo wrote: key in aa Keep in mind that D's `in` operator returns a *pointer* to the element, or null if it isn't there. If you aren't treating the return value as a pointer, you

Re: Unexpected behaviour in associative array

2019-04-19 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 19 April 2019 at 12:37:10 UTC, Arredondo wrote: Here's a reasonably-sized code fragment that demonstrates the issue. Oh dear, I don't know what's going on there. It might just be that toHash is secretly dependent on various attributes in the signature. I'd try to match the attrs

Re: Unexpected behaviour in associative array

2019-04-19 Thread Arredondo via Digitalmars-d-learn
On Friday, 19 April 2019 at 11:32:17 UTC, Andre Pany wrote: Could you please post the coding, otherwise it is quite hard to help you. Kind regards Andre Yes, I'm working on isolating the problem. It's a bit laborious because the custom Struct is actually a wrapper around an ndslice

Re: Unexpected behaviour in associative array

2019-04-19 Thread Andre Pany via Digitalmars-d-learn
On Friday, 19 April 2019 at 12:03:33 UTC, Arredondo wrote: On Friday, 19 April 2019 at 11:55:41 UTC, Andre Pany wrote: https://dub.pm/commandline.html#dustmite Thanks, but it appears that this tool is used to isolate the cause of build errors, and I'm not having build errors, just

Re: How to debug long-lived D program memory usage?

2019-04-19 Thread Alex via Digitalmars-d-learn
On Friday, 19 April 2019 at 03:27:04 UTC, Adam D. Ruppe wrote: On Friday, 19 April 2019 at 02:58:34 UTC, Alex wrote: Curious, what are these programs? A terminal emulator gui (like xterm), a detachable terminal emulator (like gnu screen), a slack client, an irc client, and a bunch of http

Re: Unexpected behaviour in associative array

2019-04-19 Thread Arredondo via Digitalmars-d-learn
On Friday, 19 April 2019 at 12:48:32 UTC, Adam D. Ruppe wrote: It might just be that toHash is secretly dependent on various attributes in the signature. You nailed it. This was it. It was not trivial to add the missing @safe and const attributes, but it worked. Thanks!

Re: gtkDcoding Blog Post # 28 - Menu II - CheckMenuItem

2019-04-19 Thread number via Digitalmars-d-learn
On Friday, 19 April 2019 at 12:12:28 UTC, Ron Tarrant wrote: Even though it's Good Friday, there's still a new blog post. As the thread title says, it's about using the CheckMenuItem, two examples this time. You can find it here: http://gtkdcoding.com/2019/04/19/0028-checkmenuitems.html

Re: Unexpected behaviour in associative array

2019-04-19 Thread JN via Digitalmars-d-learn
On Friday, 19 April 2019 at 12:37:10 UTC, Arredondo wrote: Here's a reasonably-sized code fragment that demonstrates the issue. I hope the comments along the way are descriptive enough Hmm. Have you tried using a different compiler or 32/64 bit? I had a weird "null out of nowhere" bug going

Re: How to debug long-lived D program memory usage?

2019-04-19 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 19 April 2019 at 17:30:50 UTC, Alex wrote: I was thinking you might be doing stuff like running a security system that did computer vision, or some type of advanced house monitoring and control(voice activated doors or something) ;) LOL, now *that* would be totally useless! Of

Re: gtkDcoding Blog Post # 28 - Menu II - CheckMenuItem

2019-04-19 Thread Ron Tarrant via Digitalmars-d-learn
On Friday, 19 April 2019 at 17:36:34 UTC, number wrote: The function's closing comments (first code example) need some maintenance, 'exit' also in the code on the page itself: ``` } // exit() ... } // keep() ... } // toss() ``` :) Thanks, as always,

Re: Unexpected behaviour in associative array

2019-04-19 Thread H. S. Teoh via Digitalmars-d-learn
On Fri, Apr 19, 2019 at 08:15:22PM +, Arredondo via Digitalmars-d-learn wrote: > On Friday, 19 April 2019 at 12:48:32 UTC, Adam D. Ruppe wrote: > > It might just be that toHash is secretly dependent on various > > attributes in the signature. > > > > You nailed it. This was it. It was not