Re: Strange behavior of opEquals for structs

2019-06-19 Thread harfel via Digitalmars-d-learn
On Wednesday, 19 June 2019 at 17:15:31 UTC, Ali Çehreli wrote: On 06/19/2019 08:28 AM, harfel wrote: You need to define toHash() member function as well: https://dlang.org/spec/hash-map.html#using_struct_as_key Ali Thanks Ali, This fixed my problem, of course. Amazing that such a

Strange behavior of opEquals for structs

2019-06-19 Thread harfel via Digitalmars-d-learn
I am trying to overload opEquals for a struct. The struct will hold class objects that define their own opEquals so the default bitwise comparison is not good for me. Everything works nicely if I compare the structs directly. Yet when they are used as keys in an associative array, the code

saving std.random RNG state

2018-12-17 Thread harfel via Digitalmars-d-learn
I am looking for a way to serialize/deserialize the state of the std.random.Random number generator, ideally using orange (https://github.com/jacob-carlborg/orange) or another serialization library. From looking at the module source code, I understand how to seed a random number generator with

Re: pyd: implementing __hash__ and __str__ for PyD wrapped classes

2017-04-05 Thread harfel via Digitalmars-d-learn
On Wednesday, 5 April 2017 at 11:39:47 UTC, Nicholas Wilson wrote: On Wednesday, 5 April 2017 at 09:31:09 UTC, harfel wrote: Dear all, [...] Following the documentation and code examples, I got the basic functionality working. However, I am struggling with implementing the magic functions

pyd: implementing __hash__ and __str__ for PyD wrapped classes

2017-04-05 Thread harfel via Digitalmars-d-learn
Dear all, Relatively new to D in general and PyD in particular, I am trying to wrap some D classes I wrote for use in Python. Following the documentation and code examples, I got the basic functionality working. However, I am struggling with implementing the magic functions __str__ and