|
Author |
Type(*) |
Description |
Notation |
Clutter |
1 |
Uwe |
Deep(?) |
Pretty much C++ const (?) |
typename const [], typename const * |
100 |
2 |
Andrew |
Shallow |
new (super)types: immutable array and immutable pointer |
typename #[], typename *[] |
50 |
3 |
Nod (xs0) |
Shallow |
Delphi style constness, only for arrays (?) |
typename[rw], typename[ro] |
60 |
4 |
Eugene |
Shallow |
Pretty much inversed variant #2 but all arrays and pointers(?) are readonly by default. |
var typename [] - read-write typename [] - read-only |
25-30 |
5 |
Ben (ref Walter) |
Deep(?) |
Extending meaning of 'in'/'out' or 'final'. |
out typename[], final typename[] (?) - out typename*, final typename* |
? |
(*) Types of constness
Deep:
In C++ const typename[] - means that you cannot directly modify members of array neither by assigning
new values to array elements nor calling methods non-marked as const - modifying instances explicitly. This apply to the whole depth of object hierachy - if arrays containing objects and that objects contain member objects then modifying methods disbaled to the whole depth of structures. This is why C++ const considered as "cluttering" -
you cannot take a constant reference to the object and pass it to the function with non-constant parameter - need to define const everywhere. Clutter but ultimate (as declaration method).
Shallow:
typename #[] - means that you cannot directly modify members of array by assigning new values to its elements and you cannot modify array length as in previous case. If members of the array are references to objects then this method does not propagate constness to contained objects. So you can call methods modifying objects themselves. Thus this method has "clutter factor" value significantly less.
Question remains of what to do with arrays containing structures.
As structures contain members which can be accessed independently then const protection should apply to
that memebers ( and methods ) too.