Extended Type Design.
Andrei Alexandrescu (See Website For Email)
SeeWebsiteForEmail at erdani.org
Fri Mar 16 02:43:19 PDT 2007
eao197 wrote:
> On Fri, 16 Mar 2007 00:16:48 +0300, Andrei Alexandrescu (See Website For
> Email) <SeeWebsiteForEmail at erdani.org> wrote:
>
>> a) final - a simple storage class controlling the immutability of the
>> bits allocated for the symbol per se;
>>
>> b) const - type qualifier meaning an immutable view of an otherwise
>> modifiable data. const does not control the bits of the object, only
>> the storage addressed indirectly by it (transitively);
>>
>> c) "superconst" - denoted as "const!" or "super const": type qualifier
>> meaning that the data is genuinely unmodifiable.
>
> Great!
>
> What about the influence of this storage classes on class method's
> signatures? Is this will be in D:
>
> class Data { ... }
>
> class Container {
> // non-const access to data.
> Data data() { ... }
> // const access to data.
> const Data data() const { ... }
> }
>
> void useContainer( const Container c ) {
> auto d = c.data(); // the type of d is 'const Data'.
> ...
> }
>
> ?
Yes, that's part of the plan. Moreover, you'll likely have the ability
to define const-transporting methods (methods that look identical but
only need to pass the const of the object out to the return value) only
once. This has been a source of annoyance in certain C++ idioms.
Andrei
More information about the Digitalmars-d
mailing list