Re: Unexpected behaviour in associative array

2019-04-21 Thread Arredondo via Digitalmars-d-learn
On Sunday, 21 April 2019 at 00:13:15 UTC, 9il wrote: In the latest release you can do yourSlice.lightConst.field lightConst converts from const slice to slice of const. I will add const and immutable field to the next major release. That is very good to know. BWT, I think ndslice is an

Re: Unexpected behaviour in associative array

2019-04-20 Thread 9il via Digitalmars-d-learn
On Saturday, 20 April 2019 at 22:16:22 UTC, Arredondo wrote: On Saturday, 20 April 2019 at 14:24:34 UTC, 9il wrote: On Friday, 19 April 2019 at 12:37:10 UTC, Arredondo wrote: Slice!(Contiguous, [2], byte*) payload; BTW, any reason not to use the new version of ndslice? For new API it

Re: Unexpected behaviour in associative array

2019-04-20 Thread Arredondo via Digitalmars-d-learn
On Saturday, 20 April 2019 at 14:24:34 UTC, 9il wrote: On Friday, 19 April 2019 at 12:37:10 UTC, Arredondo wrote: Slice!(Contiguous, [2], byte*) payload; BTW, any reason not to use the new version of ndslice? For new API it would be: Slice!(byte*, 2, Contiguous) or just Slice!(byte*,

Re: Unexpected behaviour in associative array

2019-04-20 Thread 9il via Digitalmars-d-learn
On Friday, 19 April 2019 at 12:37:10 UTC, Arredondo wrote: Slice!(Contiguous, [2], byte*) payload; BTW, any reason not to use the new version of ndslice? For new API it would be: Slice!(byte*, 2, Contiguous) or just Slice!(byte*, 2)

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

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: 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: 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 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: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 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 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: 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

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 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: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 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

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