Re: Bug in usage of associative array: dynamic array with string as a key

2023-06-30 Thread Ali Çehreli via Digitalmars-d-learn
On 6/30/23 17:42, Cecil Ward wrote: > https://dlang.org/spec/hash-map.html#testing_membership in the language > docs, under associative arrays - 13.3 testing membership. Would anyone > else care to try that example out as that might be quicker? I tried it by 1) Putting all the code inside a 'vo

Graphing

2023-06-30 Thread anonymouse via Digitalmars-d-learn
How would I go about graphing time series data (specifically, candles, moving averages, etc) in D and dynamically updating such charts? Thanks, --anonymouse

Re: Bug in usage of associative array: dynamic array with string as a key

2023-06-30 Thread Cecil Ward via Digitalmars-d-learn
On Friday, 30 June 2023 at 19:05:23 UTC, Cecil Ward wrote: I have code roughly like the following: dstring str = "name"d; uint ordinal = (( str in Decls.ordinals ) !is null) ? Decls.ordinals[ str ] : -1; struct Decls { uint[ dstring] ordinals; } //and Decls.ordinals[

Re: Bug in usage of associative array: dynamic array with string as a key

2023-06-30 Thread Cecil Ward via Digitalmars-d-learn
On Friday, 30 June 2023 at 21:25:23 UTC, H. S. Teoh wrote: On Fri, Jun 30, 2023 at 07:05:23PM +, Cecil Ward via Digitalmars-d-learn wrote: [...] It would help if you could post the complete code that reproduces the problem. Or, if you do not wish to reveal your code, reduce it to a minima

Re: Bug in usage of associative array: dynamic array with string as a key

2023-06-30 Thread mw via Digitalmars-d-learn
https://forum.dlang.org/thread/duetqujuoceancqtj...@forum.dlang.org Try HashMap see if it is still a problem. If no, then it's another example of the built in AA problem.

Re: Bug in usage of associative array: dynamic array with string as a key

2023-06-30 Thread H. S. Teoh via Digitalmars-d-learn
On Fri, Jun 30, 2023 at 07:05:23PM +, Cecil Ward via Digitalmars-d-learn wrote: [...] It would help if you could post the complete code that reproduces the problem. Or, if you do not wish to reveal your code, reduce it to a minimal case that still exhibits the same problem, so that we can see

Re: Bug in usage of associative array: dynamic array with string as a key

2023-06-30 Thread Ali Çehreli via Digitalmars-d-learn
On 6/30/23 13:16, Cecil Ward wrote: On Friday, 30 June 2023 at 19:58:39 UTC, FeepingCreature wrote: Note that you can do `uint ordinal = Decls.ordinals.get(str, -1);`. Is the second argument an ‘else’ then, my friend? Yes, .get and friends appear in this table: https://dlang.org/spec/ha

Re: Bug in usage of associative array: dynamic array with string as a key

2023-06-30 Thread Cecil Ward via Digitalmars-d-learn
On Friday, 30 June 2023 at 19:58:39 UTC, FeepingCreature wrote: On Friday, 30 June 2023 at 19:05:23 UTC, Cecil Ward wrote: I have code roughly like the following: dstring str = "name"d; uint ordinal = (( str in Decls.ordinals ) !is null) ? Decls.ordinals[ str ] : -1; struct Decls

Re: Bug in usage of associative array: dynamic array with string as a key

2023-06-30 Thread Cecil Ward via Digitalmars-d-learn
On Friday, 30 June 2023 at 20:12:08 UTC, Ali Çehreli wrote: On 6/30/23 12:05, Cecil Ward wrote: > I have code roughly like the following: > > dstring str = "name"d; Aside: One almost never needs dstring. > uint ordinal = (( str in Decls.ordinals ) !is null) ? > Decls.ordinals[ str ]

Re: Bug in usage of associative array: dynamic array with string as a key

2023-06-30 Thread Ali Çehreli via Digitalmars-d-learn
On 6/30/23 12:05, Cecil Ward wrote: > I have code roughly like the following: > > dstring str = "name"d; Aside: One almost never needs dstring. > uint ordinal = (( str in Decls.ordinals ) !is null) ? > Decls.ordinals[ str ] : -1; > > struct Decls > { > uint[ dstring] ordina

Re: Bug in usage of associative array: dynamic array with string as a key

2023-06-30 Thread FeepingCreature via Digitalmars-d-learn
On Friday, 30 June 2023 at 19:05:23 UTC, Cecil Ward wrote: I have code roughly like the following: dstring str = "name"d; uint ordinal = (( str in Decls.ordinals ) !is null) ? Decls.ordinals[ str ] : -1; struct Decls { uint[ dstring] ordinals; } //and Decls.ordinals[

Bug in usage of associative array: dynamic array with string as a key

2023-06-30 Thread Cecil Ward via Digitalmars-d-learn
I have code roughly like the following: dstring str = "name"d; uint ordinal = (( str in Decls.ordinals ) !is null) ? Decls.ordinals[ str ] : -1; struct Decls { uint[ dstring] ordinals; } //and Decls.ordinals[ str ] = ordinal_counter++; The problem is that it always r

Re: IntelliJ D language plugin

2023-06-30 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
I use it and contribute to it ;)

IntelliJ D language plugin

2023-06-30 Thread Dmitry Olshansky via Digitalmars-d-learn
Have anyone had any luck with it? So far I'm trying to install DMD as SDK but it fails with not a valid D compiler home. -- Dmitry Olshansky https://olshansky.me

Re: Debugging by old fashioned trace log printfs / writefln

2023-06-30 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, June 29, 2023 12:27:22 PM MDT Cecil Ward via Digitalmars-d-learn wrote: > I’m trying to debug my D program with old-fashioned printfs stuck > in various strategic places, actually using writefln(). My > problem is that the addition of printf fights with the existing > declarations for

Re: is Dlang support Uniform initialization like c++

2023-06-30 Thread Ali Çehreli via Digitalmars-d-learn
On 6/30/23 08:18, lili wrote: How too wirte this: addPoint({4,5}, {4,6}) In this case, arrays are better but only if you don't define a constructor, which you don't need for simple types like Point below: struct Point { int x; int y; } void main() { // The type is explicit on t

Re: Debugging by old fashioned trace log printfs / writefln

2023-06-30 Thread H. S. Teoh via Digitalmars-d-learn
On Fri, Jun 30, 2023 at 03:43:14PM +, Cecil Ward via Digitalmars-d-learn wrote: [...] > Since I can pass my main function some compile-time-defined input, the > whole program should be capable of being executed with CTFE, no? So in > that case pragma( msg ) should suffice for a test situation?

Re: is Dlang support Uniform initialization like c++

2023-06-30 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/30/23 11:18 AM, lili wrote:     struct Point { int x; int y;   this(int x, int y) { this.x =x; this.y=y;}     }     void addPoint(Point a, Point b) {    ...     } How too wirte this: addPoint({4,5}, {4,6}) You have to write `Point(4, 5)`. The advantage is we don

Re: is Dlang support Uniform initialization like c++

2023-06-30 Thread H. S. Teoh via Digitalmars-d-learn
On Fri, Jun 30, 2023 at 03:18:41PM +, lili via Digitalmars-d-learn wrote: > struct Point { > int x; > int y; > this(int x, int y) { this.x =x; this.y=y;} > } > > void addPoint(Point a, Point b) { >... > } > > How too wirte this: addPoint({4,5}, {4,6})

Re: Debugging by old fashioned trace log printfs / writefln

2023-06-30 Thread Cecil Ward via Digitalmars-d-learn
On Thursday, 29 June 2023 at 23:54:45 UTC, Chris Katko wrote: On Thursday, 29 June 2023 at 18:27:22 UTC, Cecil Ward wrote: I’m trying to debug my D program with old-fashioned printfs stuck in various strategic places, actually using writefln(). My problem is that the addition of printf fights w

is Dlang support Uniform initialization like c++

2023-06-30 Thread lili via Digitalmars-d-learn
struct Point { int x; int y; this(int x, int y) { this.x =x; this.y=y;} } void addPoint(Point a, Point b) { ... } How too wirte this: addPoint({4,5}, {4,6})

Re: Mixin and compile-time functions for code generation

2023-06-30 Thread Christian Köstlin via Digitalmars-d-learn
On 24.06.23 18:31, Cecil Ward wrote: I have a function that can be run at compile-time and which will be able to output code to be injected into the D source code stream. Can I get mixin whatever to do this for me? Mixin with a function that runs at compile-time and creates the required source