Logical const
Don
nospam at nospam.com
Thu Dec 2 12:25:49 PST 2010
Jonathan M Davis wrote:
> On Thursday, December 02, 2010 01:18:31 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.
>
> Except that doesn't inout actually produce multiple versions of the function,
No. My understanding is that the constness of the return value is
determined at the call site, but otherwise, it's as if all 'inout'
parameters were const.
> whereas with const, you only get the one?
>
> - Jonathan M Davis
More information about the Digitalmars-d
mailing list