const

Janice Caron caron800 at googlemail.com
Fri Mar 28 10:10:18 PDT 2008


On 28/03/2008, sambeau <no-spam-for-sambeau at mac.com> wrote:
> I like everything apart from "in". "in" to me is for arrays and sets.

My rationale is that in is already used in this context, but currently
only for function parameters. That is, currently

    int f(const T x);
    int f(in T x);

are identical. (Or at least, if they're not identical, I don't
understand the difference). If we're going to introduce a new keyword,
then "readonly" would certainly be the most popular choice, judging by
past posts on this newsgroup. But "in" would be good if either (a) we
wanted to keep the keyword count down, or (b) we felt that "readonly"
was too much typing.


>  "inv" would be fine though. "at" might be better than as it reminds you that it is an address.  I have floated "let" in the past too.

Neither of those suggests constancy to me, and I don't think I'd like
to see a function declaration like

    void f(let(char)[] x)

I mean, I'd take one look at that and say: "Huh?". But still, it's
good to hear opinions. The more the merrier.



More information about the Digitalmars-d mailing list