digitalmars.D.learn - in vs inout
- Arredondo (7/9) Apr 30 2020 I had been using inout for some time now for "purely input
- Adam D. Ruppe (7/9) Apr 30 2020 `inout` is more specifically for things you take in, look at,
- Steven Schveighoffer (11/17) Apr 30 2020 We have discovered actually that inout has some nice properties even if
The recent change log for v2.092.0 Beta says that with the new implementation for the `in` storage class:`in` should be the storage class of choice for purely input function parameters.I had been using inout for some time now for "purely input function parameters". Is there a case to be made in favor of const? why would be scope const preferred over scope inout? Cheers! Arredondo.
Apr 30 2020
On Thursday, 30 April 2020 at 14:00:40 UTC, Arredondo wrote:I had been using inout for some time now for "purely input function parameters".`inout` is more specifically for things you take in, look at, then pass back out. So it forms part of your return value. `const` is for when you are just looking without returning any of it. scope inout may be more appropriate if you are going to return it at all...
Apr 30 2020
On 4/30/20 10:52 AM, Adam D. Ruppe wrote:On Thursday, 30 April 2020 at 14:00:40 UTC, Arredondo wrote:We have discovered actually that inout has some nice properties even if you aren't returning it. For example: void rearrange(inout(int)*[] arr); This can actually accept const(int)*[], int*[], and immutable(int)*[] with one function. The function can edit the array without editing any of the values pointed at. But in terms of 'in' vs. 'inout', I'd say 'in' unless you have a specific reason to use inout (the above included). -SteveI had been using inout for some time now for "purely input function parameters".`inout` is more specifically for things you take in, look at, then pass back out. So it forms part of your return value.
Apr 30 2020