Re: T... args!

2022-04-29 Thread Tejas via Digitalmars-d-learn
On Friday, 29 April 2022 at 16:10:52 UTC, Salih Dincer wrote: On Friday, 29 April 2022 at 12:57:15 UTC, Steven Schveighoffer wrote: [...] I see, think it can be done with mixin: ```d template prn(alias args) { string prn() { string result = "write("; foreach(s; args.split("|"))

Re: T... args!

2022-04-29 Thread Salih Dincer via Digitalmars-d-learn
On Saturday, 30 April 2022 at 02:22:22 UTC, Tejas wrote: On Friday, 29 April 2022 at 16:10:52 UTC, Salih Dincer wrote: On Friday, 29 April 2022 at 12:57:15 UTC, Steven Schveighoffer wrote: [...] I see, think it can be done with mixin: ```d template prn(alias args) { string prn() {

Re: Is T.init allowed?

2022-04-29 Thread Dennis via Digitalmars-d-learn
On Friday, 29 April 2022 at 11:30:49 UTC, Andrey Zherikov wrote: Is it a compiler issue so this shouldn't be allowed? Members called `init` are in the process of being deprecated, see: https://github.com/dlang/dmd/pull/12512

Re: Is T.init allowed?

2022-04-29 Thread Andrey Zherikov via Digitalmars-d-learn
On Friday, 29 April 2022 at 12:05:35 UTC, Dennis wrote: On Friday, 29 April 2022 at 11:30:49 UTC, Andrey Zherikov wrote: Is it a compiler issue so this shouldn't be allowed? Members called `init` are in the process of being deprecated, see: https://github.com/dlang/dmd/pull/12512 That's

Is T.init allowed?

2022-04-29 Thread Andrey Zherikov via Digitalmars-d-learn
Seems compiler allows custom nested type with `init` name: ```d struct T { struct init {} int b = 2; } void main() { T t; writeln(t);// T(2) //writeln(T.init); // Error: cannot pass type `init` as a function argument } ``` Is it a compiler issue so this shouldn't

Re: T... args!

2022-04-29 Thread Steven Schveighoffer via Digitalmars-d-learn
On 4/28/22 10:48 PM, Salih Dincer wrote: On Thursday, 9 December 2021 at 14:34:58 UTC, Steven Schveighoffer wrote: You may want to post what you want to achieve with your code, instead of examples of what you tried, and it may allow us to make things clearer. You are likely using the wrong

Re: T... args!

2022-04-29 Thread Tejas via Digitalmars-d-learn
On Friday, 29 April 2022 at 12:57:15 UTC, Steven Schveighoffer wrote: On 4/28/22 10:48 PM, Salih Dincer wrote: [...] There is no string interpolation in D. You can use a function such as `std.conv.text` to produce a string given interleaving strings and items. Or you can use

Re: T... args!

2022-04-29 Thread Dennis via Digitalmars-d-learn
On Friday, 29 April 2022 at 15:13:08 UTC, Tejas wrote: It's not a keyword yet it's recognised specially by the compiler... What? It's not really recognized by the compiler, there's a little bit of magic to print `string` in outputted D code (e.g. error messages) instead of

Re: T... args!

2022-04-29 Thread Salih Dincer via Digitalmars-d-learn
On Friday, 29 April 2022 at 12:57:15 UTC, Steven Schveighoffer wrote: There is no string interpolation in D. You can use a function such as `std.conv.text` to produce a string given interleaving strings and items. Or you can use `std.format.format` to make it happen. I see, think it can be