Re: Is remove safe using foreach

2022-12-12 Thread Steven Schveighoffer via Digitalmars-d-learn
On 12/12/22 8:45 PM, Steven Schveighoffer wrote: for(auto r = aa.byKey, auto k = r.front; !r.empty; r.popFront) err... forgot the continual front assignment I think it's more like: for(auto r = aa.byKey; !r.empty; r.popFront) { auto k = r.front; // foreach body } -Steve

Re: Is remove safe using foreach

2022-12-12 Thread Steven Schveighoffer via Digitalmars-d-learn
On 12/12/22 7:54 PM, lili wrote: is foreach Syntactic sugar?, like for-range in C++, if it is, compiler how implement Yes it is syntax sugar. The lowering depends on what the item you're iterating is. For an associative array `byKey`, it is converting the AA into a range of keys, and

Re: Is remove safe using foreach

2022-12-12 Thread lili via Digitalmars-d-learn
is foreach Syntactic sugar?, like for-range in C++, if it is, compiler how implement

Re: Graphical progressive fill

2022-12-12 Thread Joel via Digitalmars-d-learn
On Monday, 12 December 2022 at 04:49:09 UTC, Siarhei Siamashka wrote: On Sunday, 11 December 2022 at 06:50:44 UTC, Joel wrote: I've been trying to fill in areas with a colour but can't work it out. I want something like the effect where it fills with diamonds. Not all at once but building up

Re: Is there such concept of a list in D?

2022-12-12 Thread Gregor Mückl via Digitalmars-d-learn
On Sunday, 11 December 2022 at 17:45:20 UTC, ryuukk_ wrote: There is: https://dlang.org/phobos/std_container_dlist.html Why is it called ``DList`` and not just ``List``, i have no clue The D is to indicate that it is a doubly-linked list. It maintains a forward and backward pointer chain to

Re: Is remove safe using foreach

2022-12-12 Thread Steven Schveighoffer via Digitalmars-d-learn
On 12/12/22 12:23 PM, lili wrote: ``` int[string] aa = ["ok":1, "aaa":2, "ccc":3, "ddd":4]; foreach (k ; aa.byKey) {     if (k == "aaa") {     aa.remove(k);     aa["ww"] = 33;     }     if (k == "ww") {     aa.remove(k);     aa["vv"] = 33;     }

Is remove safe using foreach

2022-12-12 Thread lili via Digitalmars-d-learn
``` int[string] aa = ["ok":1, "aaa":2, "ccc":3, "ddd":4]; foreach (k ; aa.byKey) { if (k == "aaa") { aa.remove(k); aa["ww"] = 33; } if (k == "ww") { aa.remove(k);

Re: Structure initializer VS lambda function

2022-12-12 Thread Tim via Digitalmars-d-learn
On Monday, 12 December 2022 at 08:54:33 UTC, realhet wrote: 1. checking inside (on the first hierarchy level inside {}) , => must be a struct initializer ; => must be a lambda no , and no ; => check it from the outside Some statements don't end in a semicolon, so you would also

Re: Structure initializer VS lambda function

2022-12-12 Thread Steven Schveighoffer via Digitalmars-d-learn
On 12/12/22 3:54 AM, realhet wrote: Hi, I'm writing a DLang parser and got confused of this. What is a good way to distinguish lambda functions and structure initialization blocks. Both of them are {} blocks. I'm thinking of something like this: 1. checking inside (on the first hierarchy

Re: arsd.jni

2022-12-12 Thread Adam D Ruppe via Digitalmars-d-learn
On Monday, 12 December 2022 at 11:17:47 UTC, jni wrote: It's good. But you did the java bindings by hand or is there a generator in arsd.jni for that too? It does it automatically. You compile jni.d with `-version=WithClassLoadSupport` and then write a main function that calls

Re: arsd.jni

2022-12-12 Thread jni via Digitalmars-d-learn
On Monday, 12 December 2022 at 01:28:42 UTC, Adam D Ruppe wrote: On Monday, 12 December 2022 at 01:19:23 UTC, jni wrote: The boilerplate is easy but Then the other part is a problem for me is the necessary other Java classes. They are not part of the NDK so the only way to load the jar is

Structure initializer VS lambda function

2022-12-12 Thread realhet via Digitalmars-d-learn
Hi, I'm writing a DLang parser and got confused of this. What is a good way to distinguish lambda functions and structure initialization blocks. Both of them are {} blocks. I'm thinking of something like this: 1. checking inside (on the first hierarchy level inside {}) , => must be a

Re: Is there such concept of a list in D?

2022-12-12 Thread TTK Ciar via Digitalmars-d-learn
On Sunday, 11 December 2022 at 17:45:20 UTC, ryuukk_ wrote: Why is it called ``DList`` and not just ``List``, i have no clue Probably because it is a *D*ouble-linked List :-)