const by default.

BCS BCS_member at pathlink.com
Tue Jul 4 14:17:39 PDT 2006


In article <e8bv9b$2gu8$1 at digitaldaemon.com>, Rémy Mouëza says...
>
[...]
>Why couldn't we do it using the "in" keyword ?
>

"in" allows the function to change the array in the calling function. As used
now, it has no barring on changeling the *contents* of said array.


[...]
>
>Won't we have the same troubles than in C++ ? Mainly copying the immutable
>variables to mutable ones that we would pass to the function: 

What else could you do? Assume a reference to immutable data, and a function
that takes a mutable reference. If the idea of "const" is going to have an
meaning at all, you can't pass the reference to the function because the mutable
attribute as much as says "I'll going to change this data". Unless I'm missing
something huge, you have to pass the function a copy or not use the function. 

[...]
>
>We could use the "out" keyword instead of the at sign. That might be more
>readable, or understandable.

The syntax is almost irrelevant at this point, however "out" don't seem to
intuitive to me. OTOH I can't think of any better keywords at this point.

All in all, I haven't made up my mind on how to do const. Const by default looks
viable at this point.





More information about the Digitalmars-d mailing list