any news on const/invariant?
Bill Baxter
dnewsgroup at billbaxter.com
Tue Nov 27 10:03:32 PST 2007
Janice Caron wrote:
> On Nov 27, 2007 9:13 AM, Walter Bright <newshound1 at digitalmars.com> wrote:
>> Think of it this way:
>>
>> const A f()
>>
>> means:
>>
>> const (A f())
>>
>> which applies the const to the function f, not A.
>
> Ah, but the natural interpretation of const(...) is that /everything/
> inside the brackets is const. Thus, if I write
>
> const(void f(char[] b))
>
> that "suggests" to me that b is const, since it is inside (albeit
> deeply inside) the const(...) brackets. But I only want f's "this" to
> be const, not b. Perhaps this is a case where "const at the end"
> creates a more helpful mneumonic?
What if it were
const() A f() {...}
or const(this) A f() {...}
?
--bb
More information about the Digitalmars-d
mailing list