Re: Bug in std.json or my problem

2020-04-22 Thread Craig Dillabaugh via Digitalmars-d-learn
On Wednesday, 22 April 2020 at 18:35:49 UTC, CraigDillabaugh wrote: On Wednesday, 22 April 2020 at 18:23:48 UTC, Anonymouse wrote: On Wednesday, 22 April 2020 at 17:48:18 UTC, Craig Dillabaugh wrote: clip File an issue if you have the time, maybe it will get attention. Unreported bugs can

Re: Bug in std.json or my problem

2020-04-22 Thread CraigDillabaugh via Digitalmars-d-learn
On Wednesday, 22 April 2020 at 18:23:48 UTC, Anonymouse wrote: On Wednesday, 22 April 2020 at 17:48:18 UTC, Craig Dillabaugh wrote: The crash is caused because the 'income' field with value 0.0 is output as 0 (rather than 0.0) and when it is read this is interpreted as an integer. Shouldn't

Re: Bug in std.json or my problem

2020-04-22 Thread Anonymouse via Digitalmars-d-learn
On Wednesday, 22 April 2020 at 17:48:18 UTC, Craig Dillabaugh wrote: The crash is caused because the 'income' field with value 0.0 is output as 0 (rather than 0.0) and when it is read this is interpreted as an integer. Shouldn't this work? Yes, it's just buggy. Giving it a value of an even

Bug in std.json or my problem

2020-04-22 Thread Craig Dillabaugh via Digitalmars-d-learn
So perhaps I am the only person in the world using std.json, but I was wondering if the following code should work. = import std.json; import std.conv; import std.stdio; struct Person { string name; float income;

Attribute inference within template functions

2020-04-22 Thread jmh530 via Digitalmars-d-learn
I was trying to write a function has different behavior depending on whether it is called from @nogc code or not. However, I am noticing that this does not seem possible because of the timing of attribute inference. If I call getFunctionAttributes within foo below, then it is system but then

Re: Enum conversion

2020-04-22 Thread Steven Schveighoffer via Digitalmars-d-learn
On 4/22/20 6:36 AM, Russel Winder wrote: Though for converting a ulong to a ubyte, I am assuming to!ubyte(x) is the right tool for the job. It depends! If you know that the long will fit in a ubyte, by all means just use a cast. It's the fastest option. If you have no idea the value of the

Re: Integration tests

2020-04-22 Thread aliak via Digitalmars-d-learn
On Wednesday, 22 April 2020 at 10:32:48 UTC, Russel Winder wrote: Now I discover Python, Rust, and Go have far nicer abstractions for writing Internet code than D does. Does D really not have a TcpListener abstraction? It really doesn't :( And D has so much potential as server tech with

Re: Enum conversion

2020-04-22 Thread Russel Winder via Digitalmars-d-learn
On Tue, 2020-04-21 at 15:48 -0400, Steven Schveighoffer via Digitalmars-d-learn wrote: […] > > 1. it's shorter and prettier. > 2. No cast (I avoid using cast whenever I can). > 3. No gotcha type conversions. Works for me, you have me convinced. :-) > e.g. for point 3: > > enum ZoneMember { //

Re: Integration tests

2020-04-22 Thread Russel Winder via Digitalmars-d-learn
I ended up creating the following project structure: . ├── dub.sdl ├── dub.selections.json ├── source │ ├── arcam_protocol.d │ └── main.d ├── tests │ └── integration_tests.d └── test_support └── mock_avr850 └── main.d with the following Dub control file: name "arcamclient"