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

2022-12-11 Thread zjh via Digitalmars-d-learn
On Sunday, 11 December 2022 at 07:47:35 UTC, Salih Dincer wrote: .. Thank you for your reply. I think if you take `random` values frequently, you'd better use `'array'`,am I right?

Re: Why can't rvalues be passed to a 'ref' parameter?

2022-12-11 Thread zjh via Digitalmars-d-learn
On Sunday, 11 December 2022 at 04:36:45 UTC, thebluepandabear wrote: "The main reason for this limitation is the fact that a function taking a ref parameter can hold on to that reference for later use, at a time when the rvalue would not be available." I only know that `rvalue` is a tempo

Function template as template parameter

2022-12-11 Thread Andrey Zherikov via Digitalmars-d-learn
I have this (very simplified) code: ```d void foo(alias callback)() { callback!5; } static void print(int i)() { writeln(i); } foo!print; ``` Is there a way to merge two last lines into one of a form like `foo!(...something...)`? Note that callback parameter must be compile-time parameter

Re: Function template as template parameter

2022-12-11 Thread Salih Dincer via Digitalmars-d-learn
On Sunday, 11 December 2022 at 09:43:34 UTC, Andrey Zherikov wrote: Note that callback parameter must be compile-time parameter as it represents a member of a type during introspection done by `foo`. I can't quite understand the question, this already works: ```d void foo(alias callback)() {

Re: arsd.jni

2022-12-11 Thread Adam D Ruppe via Digitalmars-d-learn
I don't know how to do much of anything on Android, but if you can post a small Java code example, I can suggest how to use it from D. You can bind many classes through the jni. The biggest limitation is you can't do callbacks or subclasses through android jni, so it is kinda limited for inter

Re: Function template as template parameter

2022-12-11 Thread Ali Çehreli via Digitalmars-d-learn
On 12/11/22 05:54, Salih Dincer wrote: > On Sunday, 11 December 2022 at 09:43:34 UTC, Andrey Zherikov wrote: >> Note that callback parameter must be compile-time parameter as it >> represents a member of a type during introspection done by `foo`. > > I can't quite understand the question, this alr

Re: Why can't rvalues be passed to a 'ref' parameter?

2022-12-11 Thread Ali Çehreli via Digitalmars-d-learn
On 12/11/22 01:25, zjh wrote: > On Sunday, 11 December 2022 at 04:36:45 UTC, thebluepandabear wrote: > >> "The main reason for this limitation is the fact that a function >> taking a ref >> parameter can hold on to that reference for later use, at a time when >> the rvalue >> would not be availabl

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

2022-12-11 Thread ryuukk_ via Digitalmars-d-learn
On Saturday, 10 December 2022 at 05:46:26 UTC, thebluepandabear wrote: In most languages there is some sort of `List` type, is that the same for D? There is: https://dlang.org/phobos/std_container_dlist.html Why is it called ``DList`` and not just ``List``, i have no clue

Re: Why can't rvalues be passed to a 'ref' parameter?

2022-12-11 Thread ryuukk_ via Digitalmars-d-learn
On Sunday, 11 December 2022 at 04:36:45 UTC, thebluepandabear wrote: Hello, I am not really understanding why rvalues cannot be passed to a 'ref' parameter, the explanation in the book about D I am reading was not clear: "The main reason for this limitation is the fact that a function takin

Re: Function template as template parameter

2022-12-11 Thread Andrey Zherikov via Digitalmars-d-learn
On Sunday, 11 December 2022 at 16:24:30 UTC, Ali Çehreli wrote: On 12/11/22 05:54, Salih Dincer wrote: > On Sunday, 11 December 2022 at 09:43:34 UTC, Andrey Zherikov wrote: >> Note that callback parameter must be compile-time parameter as it >> represents a member of a type during introspection d

Re: arsd.jni

2022-12-11 Thread jni via Digitalmars-d-learn
On Sunday, 11 December 2022 at 14:24:18 UTC, Adam D Ruppe wrote: I don't know how to do much of anything on Android, but if you can post a small Java code example, I can suggest how to use it from D. You can bind many classes through the jni. The biggest limitation is you can't do callbacks or

Re: arsd.jni

2022-12-11 Thread Adam D Ruppe via Digitalmars-d-learn
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 to use jni? Is that correct? I haven't updated this for a while,

Re: Why can't rvalues be passed to a 'ref' parameter?

2022-12-11 Thread zjh via Digitalmars-d-learn
On Sunday, 11 December 2022 at 16:48:57 UTC, Ali Çehreli wrote: However, the situation has changed in D: It has been possible to pass rvalues by reference through the magic of 'in' parameters. This currently requires the -preview=in compiler switch, which makes 'in' parameters imply 'const sco

Re: Graphical progressive fill

2022-12-11 Thread thebluepandabear via Digitalmars-d-learn
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 in the main program loop. # # # # #

Re: Graphical progressive fill

2022-12-11 Thread Siarhei Siamashka via Digitalmars-d-learn
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 in the main program loop. I'm not sure if I understood the question co

Re: Graphical progressive fill

2022-12-11 Thread Ferhat Kurtulmuş via Digitalmars-d-learn
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 in the main program loop. # # # # #

Re: Graphical progressive fill

2022-12-11 Thread Siarhei Siamashka via Digitalmars-d-learn
On Monday, 12 December 2022 at 06:02:27 UTC, Ferhat Kurtulmuş wrote: https://rosettacode.org/wiki/Bitmap/Flood_fill The https://rosettacode.org/wiki/Bitmap/Flood_fill#D looks like a DFS implementation. The end result is the same, but the order in which the pixels to fill are reached is differ