Encapsulate arguments

Adam D. Ruppe destructionator at gmail.com
Wed Jan 1 15:11:48 PST 2014


On Wednesday, 1 January 2014 at 23:00:33 UTC, alex burton wrote:
> In D this would be void bar(in Init init) which makes init const

You should just take Init, without the in.

"in" means that you won't modify AND that you won't let any 
reference to the argument escape the function's scope. The second 
part isn't enforced by the compiler right now, but this may 
change at some point.

"in" basically is "look, don't keep", and since ctor arguments 
are often kept in the class, it isn't ideal there.

But plain non-const, non-in structs should be fine, that works 
the same way as a regular function argument list.


More information about the Digitalmars-d mailing list