Using "in/out/ref"

David Ferenczi raggae at
Wed Jun 18 01:51:46 PDT 2008

I would like to better understand the rationale of in/out/ref keywords, and
how they should be used.

If I don't use them, the function gets a mutable copy of the variable. So
the original variable won't change. At least in case of integral types.
(C-like convention?) In case of objects (object references?), or pointers
the function gets a mutable reference or a mutable pointer. This means that
the function can change the object, which is referred by the pointer or
reference. Is it right? Does this also mean that in case of objects or
pointes ref is the default?

In case of object references I would always use one of the in/out/ref
keywords to be explicit. (It could be also enforced by the compiler to be
explicit on references.)

Please correct me, if I'm wrong.


More information about the Digitalmars-d-learn mailing list