'final' variables
James Dennett
jdennett at acm.org
Tue Mar 20 23:13:38 PDT 2007
Walter Bright wrote:
> Lionello Lunesu wrote:
>> And if you later want to rebind 'i' you'll have to change the
>> interface. Lose-lose?
>
> Although final is specified in the interface, it is not part of the
> interface. It only affects the implementation of the interface. You'll
> be able to change it without affecting any users of the interface.
Same as C++ here then: the declaration
void f(int);
is identical to
void f(int const);
though in the corresponding definition the implementation
gets checking that it doesn't alter its local copy of the
int if it uses const qualification. It's quite legal
(and quite common) to declare
void f(int);
and then define f as
void f(int const value)
{
// ... code here can't accidentally change the local value
}
-- James
More information about the Digitalmars-d
mailing list