in reply to Re: const correctness
in thread const correctness
Perl has Readonly and constant which provide the same functionality.
They're not the same thing. const is not about constructing immutable values it's about being able to declare that "in the following code, the contents of this variable should not be modified, if you see me trying to modify it, throw a compile-time error".
It's also about making a promise in your API which the caller knows will be kept because it has been checked at compile-time. Of course you can force the compiler to let you break the promise using a cast but it can't happen as an unanticipated side-effect or typo.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: const correctness
by BrowserUk (Patriarch) on May 14, 2008 at 14:47 UTC |