[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: "const" scalars
From: |
Paul Eggert |
Subject: |
Re: "const" scalars |
Date: |
Mon, 12 Apr 2010 13:50:06 -0700 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) |
Jim Meyering <address@hidden> writes:
> By "local variables" you must mean "local scalar variables".
> You wouldn't argue for dropping "const" as a pointer attribute.
Yes, that's right. That is, it's fine to have this:
{
char const *p = &a[i];
...
}
because the 'const' is talking about p's value, not about p itself, and
the value's const-ness is often non-obvious. In constrast, it's dubious
to have this:
{
char *const p = &a[i];
...
}
because this 'const' is talking about p itself, and p is a local
variable so it is typically obvious (by inspecting the "...") whether p
varies.
> In any case, don't worry: I'm not about to add "const"
> to all scalar declarations.
Yay! Thanks.
- Re: [PATCH] Don't error out if stdin/stdout/stderr was already closed., (continued)
- Re: const local variables, Bruno Haible, 2010/04/11
- Re: const local variables, James Youngman, 2010/04/11
- Re: const local variables, Jim Meyering, 2010/04/11
- Re: const local variables, Paul Eggert, 2010/04/11
- "const" scalars, Jim Meyering, 2010/04/12
- Re: "const" scalars, Ben Pfaff, 2010/04/12
- Re: "const" scalars, Jim Meyering, 2010/04/12
- Re: "const" scalars,
Paul Eggert <=
- Re: const local variables, Ludovic Courtès, 2010/04/12