Re: pipeProcess output to hash string

2023-09-11 Thread vino via Digitalmars-d-learn
On Monday, 11 September 2023 at 22:08:54 UTC, Christian Köstlin wrote: On 09.09.23 17:44, Vino wrote: Hi All,   Request your help on how to convert the output of std.process.pipeProcess to hash string ``` auto test(in Redirect redirect=Redirect.stdout | Redirect.stderr) {     import std

Re: Setting struct as default parameter of a function using struct literal?

2023-09-11 Thread H. S. Teoh via Digitalmars-d-learn
On Mon, Sep 11, 2023 at 10:39:00PM +, Salih Dincer via Digitalmars-d-learn wrote: > On Monday, 11 September 2023 at 22:13:25 UTC, H. S. Teoh wrote: > > > > Because sometimes I want a specific type. > > > > it's possible... > > ```d > alias ST = Options; > void specificType(ST option = ST()

Re: Setting struct as default parameter of a function using struct literal?

2023-09-11 Thread Steven Schveighoffer via Digitalmars-d-learn
On Monday, 11 September 2023 at 19:59:37 UTC, ryuukk_ wrote: I would love to be able to use C style designated initialization everywhere too.. Recent version of D added named arguments so you can do something like: ```D void someFunction(Options option = Options(silenceErrors: false)) `

Re: Setting struct as default parameter of a function using struct literal?

2023-09-11 Thread Salih Dincer via Digitalmars-d-learn
On Monday, 11 September 2023 at 22:13:25 UTC, H. S. Teoh wrote: Because sometimes I want a specific type. it's possible... ```d alias ST = Options; void specificType(ST option = ST()) { if(option) { assert(false); } else assert(true); } void main() { specificType(); // No er

Re: Setting struct as default parameter of a function using struct literal?

2023-09-11 Thread H. S. Teoh via Digitalmars-d-learn
On Mon, Sep 11, 2023 at 10:05:11PM +, Salih Dincer via Digitalmars-d-learn wrote: > On Monday, 11 September 2023 at 20:17:09 UTC, H. S. Teoh wrote: > > > > Someone should seriously come up with a way of eliminating the > > repeated type name in default parameters. > > Why not allow it to be

Re: pipeProcess output to hash string

2023-09-11 Thread Christian Köstlin via Digitalmars-d-learn
On 09.09.23 17:44, Vino wrote: Hi All,   Request your help on how to convert the output of std.process.pipeProcess to hash string ``` auto test(in Redirect redirect=Redirect.stdout | Redirect.stderr) {     import std.process;     import std.digest.crc;     import std.stdio: writeln;   

Re: Setting struct as default parameter of a function using struct literal?

2023-09-11 Thread Salih Dincer via Digitalmars-d-learn
On Monday, 11 September 2023 at 20:17:09 UTC, H. S. Teoh wrote: Someone should seriously come up with a way of eliminating the repeated type name in default parameters. Why not allow it to be flexible enough by using a template parameter? ```d enum Options : bool { silenceErrorsOff, sile

Re: Setting struct as default parameter of a function using struct literal?

2023-09-11 Thread H. S. Teoh via Digitalmars-d-learn
On Mon, Sep 11, 2023 at 07:59:37PM +, ryuukk_ via Digitalmars-d-learn wrote: [...] > Recent version of D added named arguments so you can do something > like: > > ```D > void someFunction(Options option = Options(silenceErrors: false)) > ``` > > I don't like the useless repeating "option opti

Re: Setting struct as default parameter of a function using struct literal?

2023-09-11 Thread ryuukk_ via Digitalmars-d-learn
On Monday, 11 September 2023 at 17:51:04 UTC, BoQsc wrote: https://docarchives.dlang.io/v2.073.0/spec/struct.html#struct-literal I would like to set function's default struct for a function in a way that it would be visible for the reader to see what options are set. Something like `Options op

Re: Setting struct as default parameter of a function using struct literal?

2023-09-11 Thread Salih Dincer via Digitalmars-d-learn
On Monday, 11 September 2023 at 17:51:04 UTC, BoQsc wrote: Here is an example of what I would hope for to work but it surely does not work: If I were you I would use enum, look at my code: ```d enum Options { silenceErrors = false } void someFunction (Options option = Options.silenceError

Setting struct as default parameter of a function using struct literal?

2023-09-11 Thread BoQsc via Digitalmars-d-learn
https://docarchives.dlang.io/v2.073.0/spec/struct.html#struct-literal I would like to set function's default struct for a function in a way that it would be visible for the reader to see what options are set. Something like `Options option = {silenceErrors: false}` Here is an example of what