[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Emacs rewrite in a maintainable language
From: |
Oleh Krehel |
Subject: |
Re: Emacs rewrite in a maintainable language |
Date: |
Tue, 13 Oct 2015 13:27:49 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux) |
Paul Eggert <address@hidden> writes:
> On 10/12/2015 08:17 AM, Oleh Krehel wrote:
>> Quoting the Emacs sources:
>>
>> # define MIN(a,b) ((a) < (b) ? (a) : (b))
>> #define streq(X, Y) (*(X) == *(Y) && strcmp ((X) + 1, (Y) + 1) == 0)
>> #define SET_FLAG(F, FLAG) ((F) |= (FLAG))
>> #define HAS_FLAG(F, FLAG) (((F) & (FLAG)) != 0)
>> #define xnew(n, Type) ((Type *) xmalloc ((n) * sizeof (Type)))
>> #define xrnew(op, n, Type) ((op) = (Type *) xrealloc (op, (n) * sizeof
>> (Type)))
>> #define switch_line_buffers() (curndx = 1 - curndx)
>> #define curlinepos (lbs[curndx].linepos)
>> #define BVAR(buf, field) ((buf)->field ## _)
>>
>> Some of these can be replaced with plain type checked C++
>
> Only BVAR belongs to the Emacs core. The other macros belong to
> auxiliary executables that presumably would be unaffected by any
> rewrite of the core. Anyway, for fun I just now replaced streq,
> SET_FLAG, and HAS_FLAG with functions, in the attached patch. More
> work needs to be done in this area but one step at a time....
Thanks, Paul.
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.
I have to admit that I haven't seen the "char const *" variation
anywhere before. Just to get another sample, I looked at the Linux
sources; their ratio is 31961:189 in favor of "const char *".
If no one deems it counter-productive, I'd like to switch all const
pointers to a single "const char *" style. If we want more people to be
comfortable with the C sources, style and consistency is important.
Oleh
- Re: Emacs rewrite in a maintainable language, (continued)
- Re: Emacs rewrite in a maintainable language, Oleh Krehel, 2015/10/15
- 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 <=
- 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, 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, 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