On Wed, Mar 04, 2015 at 02:05:45AM +0000, anonymous via Digitalmars-d wrote: > On Wednesday, 4 March 2015 at 01:17:00 UTC, H. S. Teoh wrote: > >The 'in' modifier is the same as 'const' when applied to function > >parameters, but writing 'in' documents that the parameters are input > >parameters that won't be modified by the function. > > You forgot to mention "scope". "in" is short for "scope const". > 'scope' means that the argument is used only in this run of the > function; it's not stored anywhere (a global, a struct/class member, > ...).
Ah, you're right, I forgot about that. > >(Conversely, writing 'out' documents that the parameter is an output > >parameter: the compiler initializes it to its default state, and the > >function (presumably) stores its output value(s) in that parameter > >before returning. Semantically, 'out' is the same as mutable, which > >is unmarked in D. But writing 'out' helps code maintainability by > >documenting the intent of function parameters, so that readers of > >your code don't have to guess what the purpose of the parameter might > >be and how it should be used.) > > You forgot to mention that "out" parameters work like "ref" parameters > (plus resetting to default value). That is, arguments are passed by > reference; changes that the function makes affect the given lvalue at > the call site. Right again. I really need to check what I write before posting... :-( Thanks for the corrections! T -- Lottery: tax on the stupid. -- Slashdotter
