const

Janice Caron caron800 at googlemail.com
Fri Mar 28 08:12:59 PDT 2008


So, while we're having (...another...) const rethink, here's my list
of "ideals".

(1) Rename everything. Like many other people, I've always thought the
existing names weren't quite right.

    BEFORE -> AFTER
    const -> in
    invariant -> const
    enum -> const

This will mean we lose the distinction between the current usage of
"const" and "in". Big deal! Who understands the difference anyway?

(2) Manifest constants just work. If something is declared /fully/
const, then you cannot take the address of it.

    const PI = 3.14;
    auto p = Π /*ERROR*/

If you want a constant you can take the address of, declare it as "in". e.g.

    in E = 2.72;
    auto p = &E; /*OK*/

(3) Rebindable references to const classes.

    in(T)& c;

...which of course shall be a syntax error if T is not a class. (Same
as Andrei's proposed Rebindable!(const(T))).

(4) Better syntax for const member functions.

    in(this) T f()



Well, that's my list. Probably others will have a different list. But
these are what I see as the things that people are most unhappy about,
and fixing these would buy us a /huge/ amount of goodwill.

At least, in my opinion. But I'm positive that others will chime with
additional opinions.



More information about the Digitalmars-d mailing list