Re: write once type?

2021-04-29 Thread Steven Schveighoffer via Digitalmars-d-learn
On 4/29/21 5:31 PM, sighoya wrote: On Tuesday, 20 April 2021 at 19:56:33 UTC, Steven Schveighoffer wrote: Not only that, but I may also want to keep processing the loop and do something different if the value has already been set instead of returning immediately, which necessitates a second

Re: dlang vs crystal-language

2021-04-29 Thread Alain De Vos via Digitalmars-d-learn
What is the importance of type-annotations in which cases. @X @Y @Z makes code sometimes unreadable. Sometimes there is a good reason

Re: write once type?

2021-04-29 Thread sighoya via Digitalmars-d-learn
On Tuesday, 20 April 2021 at 19:56:33 UTC, Steven Schveighoffer wrote: Not only that, but I may also want to keep processing the loop and do something different if the value has already been set instead of returning immediately, which necessitates a second loop. Can I ask why you require to

Re: nothrow and std.exception.ifThrown

2021-04-29 Thread novice2 via Digitalmars-d-learn
Thank you Imperatron, Ali both variants ```d scope(failure) assert(0); ``` ```d collectException ``` works! Thank Meta The reason for this, apparently, is in the definition of `ifThrown` i tried to modify ifThrown adding nothrow, but compiler dont understand, that second parameter cant

Re: dlang vs crystal-language

2021-04-29 Thread sighoya via Digitalmars-d-learn
On Wednesday, 28 April 2021 at 22:41:03 UTC, Alain De Vos wrote: What are the strengths and weaknesses comparing the two languages ? I can name a strength of dlang is the working binding to tk and gtk. Less type annotations, fewer guarantees, less compile performance as cons.

Re: nothrow and std.exception.ifThrown

2021-04-29 Thread Ali Çehreli via Digitalmars-d-learn
On 4/29/21 9:02 AM, novice2 wrote: > format() can throw. In order to throw for an int, I added a foo(x) expression to prove that the code works. > I don't want embrace format into try..catch block, > and i found elegant std.exception.ifThrown. There are collectException and

Re: nothrow and std.exception.ifThrown

2021-04-29 Thread Meta via Digitalmars-d-learn
On Thursday, 29 April 2021 at 16:02:20 UTC, novice2 wrote: Hello. I need use std.format.format() in nothrow function. format() can throw. For this case i have special default string. I don't want embrace format into try..catch block, and i found elegant std.exception.ifThrown. But DMD say

Re: mir - Help on how to transform multidimentional arrays.

2021-04-29 Thread Newbie via Digitalmars-d-learn
On Thursday, 29 April 2021 at 15:56:48 UTC, jmh530 wrote: On Thursday, 29 April 2021 at 15:26:15 UTC, Newbie wrote: [snip] Forgot to add the the first array was created using the following code. auto base = iota(2, 5, 3); What you're basically asking for the first one is to convert for

Re: nothrow and std.exception.ifThrown

2021-04-29 Thread Imperatorn via Digitalmars-d-learn
On Thursday, 29 April 2021 at 16:02:20 UTC, novice2 wrote: Hello. I need use std.format.format() in nothrow function. format() can throw. For this case i have special default string. I don't want embrace format into try..catch block, and i found elegant std.exception.ifThrown. But DMD say

nothrow and std.exception.ifThrown

2021-04-29 Thread novice2 via Digitalmars-d-learn
Hello. I need use std.format.format() in nothrow function. format() can throw. For this case i have special default string. I don't want embrace format into try..catch block, and i found elegant std.exception.ifThrown. But DMD say "ifThrown not nothrow" https://run.dlang.io/is/kXtt5q ```d

Re: mir - Help on how to transform multidimentional arrays.

2021-04-29 Thread jmh530 via Digitalmars-d-learn
On Thursday, 29 April 2021 at 15:56:48 UTC, jmh530 wrote: What you're basically asking for the first one is to convert for row major to column major. There doesn't seem to be a specific function for that, but you can piece it together. The second one is just applying allReversed to the

Re: mir - Help on how to transform multidimentional arrays.

2021-04-29 Thread jmh530 via Digitalmars-d-learn
On Thursday, 29 April 2021 at 15:26:15 UTC, Newbie wrote: [snip] Forgot to add the the first array was created using the following code. auto base = iota(2, 5, 3); What you're basically asking for the first one is to convert for row major to column major. There doesn't seem to be a

Re: mir - Help on how to transform multidimentional arrays.

2021-04-29 Thread Newbie via Digitalmars-d-learn
On Thursday, 29 April 2021 at 15:22:55 UTC, Newbie wrote: mir - Help on how to transform multidimentional arrays. -- | 0 1 2| | 3 4 5| | 6 7 8| | 9 10 11| |12 13 14| -- |15 16 17| |18 19 20| |21 22 23| |24 25 26| |27 28 29| -- How can i transform it into the

mir - Help on how to transform multidimentional arrays.

2021-04-29 Thread Newbie via Digitalmars-d-learn
mir - Help on how to transform multidimentional arrays. -- | 0 1 2| | 3 4 5| | 6 7 8| | 9 10 11| |12 13 14| -- |15 16 17| |18 19 20| |21 22 23| |24 25 26| |27 28 29| -- How can i transform it into the following types of arrays. -- | 0 10 20| | 1 11 21| |

Re: dlang vs crystal-language

2021-04-29 Thread Imperatorn via Digitalmars-d-learn
On Thursday, 29 April 2021 at 05:54:24 UTC, Berni44 wrote: On Thursday, 29 April 2021 at 05:41:45 UTC, Imperatorn wrote: Crystal has no installer for Windows Is this a strength or a weakness? (SCNR) lol :) In all seriousness though. Since it a quite large population of the world, it's a

Re: Deriving a D-class from a CPP-class

2021-04-29 Thread user1234 via Digitalmars-d-learn
On Thursday, 29 April 2021 at 06:38:53 UTC, evilrat wrote: On Wednesday, 28 April 2021 at 19:46:00 UTC, Alain De Vos wrote: It is rather clear what I want to achieve but virtual functions give me headache because dlang does not now the word virtual. It's virtual by default. The opposite is

Re: Deriving a D-class from a CPP-class

2021-04-29 Thread evilrat via Digitalmars-d-learn
On Wednesday, 28 April 2021 at 19:46:00 UTC, Alain De Vos wrote: It is rather clear what I want to achieve but virtual functions give me headache because dlang does not now the word virtual. It's virtual by default. The opposite is `final`.

Re: dlang vs crystal-language

2021-04-29 Thread Siemargl via Digitalmars-d-learn
On Wednesday, 28 April 2021 at 22:41:03 UTC, Alain De Vos wrote: What are the strengths and weaknesses comparing the two languages ? I can name a strength of dlang is the working binding to tk and gtk. Crystal is Web-only focused. And Crystal is not popular, even compared to D.