any news on const/invariant?

Janice Caron caron800 at googlemail.com
Tue Nov 27 02:56:21 PST 2007


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?



More information about the Digitalmars-d mailing list