return const proposals

Denis Koroskin 2korden at gmail.com
Mon Oct 6 18:03:41 PDT 2008


On Tue, 07 Oct 2008 03:41:30 +0400, Jason House  
<jason.james.house at gmail.com> wrote:

> ore-sama Wrote:
>
>> I wanted to use const system, but the kitchen sink syndrome SUDDENLY  
>> killed me :(
>> There is return storage class attribute
>>
>> const(char[]) capitalize(return const(char[]) s) { ... }
>
>
> What about the following?
> return(char[]) capitalize(return(char[]) s){ ... }
>
> It's shorter, supports both const and invariant, and is clear when  
> looking at the return type
>

Other suggestion:
sameconst(char[]) capitalize(sameconst(char[]) s){ ... }

or just:
same(char[]) capitalize(same(char[]) s){ ... } // this one is even shorter!

It says that both input and output parameters have same constness.



More information about the Digitalmars-d mailing list