digitalmars.D - `lvalueof` property on rvalues
- Basile B. (9/9) May 09 2022 what about
- Bastiaan Veelo (13/15) May 12 2022 That's what happens if you supply the `-preview=rvaluerefparam`
- Basile B. (3/18) May 12 2022 Ok, I was not aware of that. It's would be indeed useless if D
what about ```d void fun(ref int); fun(1.lvalueof); ``` previous work : https://wiki.dlang.org/DIP39 The `lvalueof` property could create a temporary variable if the exp it's used on is not already a lvalue, otherwise it would do nothing.
May 09 2022
On Monday, 9 May 2022 at 14:03:21 UTC, Basile B. wrote:[...] create a temporary variable if the exp it's used on is not already a lvalue, otherwise it would do nothing.That's what happens if you supply the `-preview=rvaluerefparam` compiler argument, right? Then this already works: ```d void fun(ref int i) {} void main() { fun(1); } ``` There is also `-preview=in`. So what is the advantage of having to add `.lvalueof`? -- Bastiaan.
May 12 2022
On Thursday, 12 May 2022 at 08:06:14 UTC, Bastiaan Veelo wrote:On Monday, 9 May 2022 at 14:03:21 UTC, Basile B. wrote:Ok, I was not aware of that. It's would be indeed useless if D can already do that implictly.[...] create a temporary variable if the exp it's used on is not already a lvalue, otherwise it would do nothing.That's what happens if you supply the `-preview=rvaluerefparam` compiler argument, right? Then this already works: ```d void fun(ref int i) {} void main() { fun(1); } ``` There is also `-preview=in`. So what is the advantage of having to add `.lvalueof`? -- Bastiaan.
May 12 2022