Logical const

Walter Bright newshound2 at digitalmars.com
Thu Dec 2 12:19:32 PST 2010


Don wrote:
> Walter Bright wrote:
>> spir wrote:
>>> What would be the consequences if D had no const, only immutable 
>>> (that, IIUC, removes the latter non-guarantee)?
>>
>> You'd have to write most every function twice, once to take immutable 
>> args and again for mutable ones.
> 
> Doesn't 'inout' do almost the same thing?
> The only difference I can see between const and inout, is that inout 
> tells which parameters could be aliased with the return value.

inout applies at the top level, but you cannot define a struct that has inout 
fields.


More information about the Digitalmars-d mailing list