Meaning of in, out and inout

Paul Backus snarwin at gmail.com
Thu Jan 20 13:28:54 UTC 2022


On Thursday, 20 January 2022 at 13:19:06 UTC, Sergey wrote:
> https://forum.dlang.org/post/17nwtnp4are5q$.1ddtvmj4e23iy.dlg@40tude.net
>
> On Tuesday, 10 May 2005 at 01:06:14 UTC, Derek Parnell wrote:
>> [...]
>
> Thanks a lot for your explanation.
> I started to learn D language recently and I have trouble with 
> understanding some part of language.
> I do your example on Linux and it works very well, especially 
> func_rthee().
> when I try to repeat code on Windows 10, I get errors:
>    Error: cannot modify `inout` expression `X[0]`
>    Error: cannot modify `inout` expression `X`
>    Error: cannot modify `inout` expression `Y`
>    Error: cannot modify `inout` expression `Y`
> Very strange situation for me.
> I expect next behavior of the parameters X and Y could get 
> value and could change it on Windows but now I am not sure what 
> is goin on.
>
> PS. I am using DMD64 D Compiler v2.098.1-dirty on Debian 10 
> Linux and Windows 10.

The explanation you quoted is from 2005, and `inout` does not 
mean the same thing in 2022 as it did in 2005.

The current meaning of inout is explained in the D language 
specification on dlang.org. Here is a link to the relevant 
section:

https://dlang.org/spec/function.html#inout-functions


More information about the Digitalmars-d-learn mailing list