[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Emacs rewrite in a maintainable language
From: |
Sergey Organov |
Subject: |
Re: Emacs rewrite in a maintainable language |
Date: |
Tue, 13 Oct 2015 16:06:08 +0300 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux) |
Oleh Krehel <address@hidden> writes:
> Alan Mackenzie <address@hidden> writes:
>
>> Hello, Oleh.
>>
>> On Tue, Oct 13, 2015 at 01:27:49PM +0200, Oleh Krehel wrote:
>>
>>> May I ask if there's a reason to not have a single style for const
>>> pointers? I get 2162 occurrences of "const char *", and 357 occurrences
>>> of "char const *" in the C sources.
>>
>> Yes there is. The two are semantically different. In one of them, it is
>> the pointer which is declared constant. In the other, it's what's
>> pointed at that's constant. Though I can never remember which is which.
>> :-(
>
> Hi Alan,
>
> Actually, "const char *" and "char const *" are absolutely equivalent in
> all regards, both in C and C++.
>
> I think you meant the difference between "const char *" and "char * const".
>
> For exactly this reason (the confusion over 3 notations, 2 of which are
> the same), I propose that we stick only to "const char *" and "char * const",
> and don't use "char const *".
People write "char const *" because it uses the general and simple rule
"'const' applies to what is to the left", that makes it easy to figure
what "char * const" means and why ('const' applies to '*' here, to
the pointer).
OTOH, "const char *", while looks more "natural", relies on additional
rule "when nothing is to the left, 'const' applies to what is to the
right".
Dunno if enforcing one form or another makes sense.
-- Sergey.
- Re: Emacs rewrite in a maintainable language, (continued)
- Re: Emacs rewrite in a maintainable language, David Kastrup, 2015/10/12
- Re: Emacs rewrite in a maintainable language, Oleh Krehel, 2015/10/12
- Re: Emacs rewrite in a maintainable language, David Kastrup, 2015/10/12
- Re: Emacs rewrite in a maintainable language, Eli Zaretskii, 2015/10/12
- Re: Emacs rewrite in a maintainable language, Paul Eggert, 2015/10/12
- Re: Emacs rewrite in a maintainable language, Oleh Krehel, 2015/10/15
- Re: Emacs rewrite in a maintainable language, Alan Mackenzie, 2015/10/13
- Re: Emacs rewrite in a maintainable language, Eli Zaretskii, 2015/10/13
- Re: Emacs rewrite in a maintainable language, David Kastrup, 2015/10/13
- Re: Emacs rewrite in a maintainable language, Oleh Krehel, 2015/10/15
- Re: Emacs rewrite in a maintainable language,
Sergey Organov <=
- Re: Emacs rewrite in a maintainable language, Artur Malabarba, 2015/10/13
- Re: Emacs rewrite in a maintainable language, David Kastrup, 2015/10/13
- Re: Emacs rewrite in a maintainable language, Artur Malabarba, 2015/10/13
- Re: Emacs rewrite in a maintainable language, David Kastrup, 2015/10/13
- Re: Emacs rewrite in a maintainable language, Oleh Krehel, 2015/10/13
- Re: Emacs rewrite in a maintainable language, David Kastrup, 2015/10/13
- Re: Emacs rewrite in a maintainable language, Eli Zaretskii, 2015/10/15
- Re: Emacs rewrite in a maintainable language, David Kastrup, 2015/10/13
- Re: Emacs rewrite in a maintainable language, Alan Mackenzie, 2015/10/15
- Re: Emacs rewrite in a maintainable language, Mathieu Lirzin, 2015/10/15