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

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

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

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

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

2022-12-10 Thread thebluepandabear via Digitalmars-d-learn
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 taking a ref parameter can hold on to that reference for later use, at a