On Fri, 27 Apr 2012 13:23:46 -0400, Jonathan M Davis <[email protected]>
wrote:
On Friday, April 27, 2012 11:18:26 Steven Schveighoffer wrote:
const should not affect code generation *at all*, except for name
mangling
(const MyStruct is a different type from MyStruct), and generating an
extra TypeInfo for const MyStruct and const MyStruct[]. Const is purely
a
compile-time concept.
Thanks to the fact that const is transitive and that it's illegal to
cast it
away to use mutation, const _can_ affect code optimizations, but I don't
know
exactly under what circumstances it does in the current compiler.
No, it can't. There can easily be another non-const reference to the same
data. Pure functions can make more assumptions, based on the types, but
it would be a very complex determination in the type system to see if two
parameters alias the same data.
Real optimization benefits come into play when immutable is there.
-Steve