[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: |
Mon, 12 Oct 2015 17:17:52 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux) |
David Kastrup <address@hidden> writes:
> Oleh Krehel <address@hidden> writes:
>> I think slowly moving the Emacs C core to C++ is a good idea.
>
> I don't, and the reasons are similar to why Linux on C++ crashed and
> burned.
I haven't investigated that topic. Could you give the summary of the
reason?
> The theory is very nice, but C++ is not a stable basis. Every 5 years
> it gets completely redefined, and the Elisp semantics don't magically
> move with that.
Not completely. I'm thinking of using only a very small subset of C++ /
superset of C:
- the C features
- classes with getters/setters (no need for inheritance)
- typed constants
- templated functions where appropriate
Essentially what good C programs do anyway, but with proper support from
the compiler. These features are supported by any version of any C++
compiler.
>> I've been trying to get into understanding Emacs C core, but it's just
>> so hard with all those macros around. I think even replacing `#define`
>> with `const` would be a huge improvement, worthwhile of the switch.
>> The second step would be to replace some macros with type checked
>> template functions.
>
> "template functions"? Seriously?
Yes, very.
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++
functions. Others can be replaced with templated C++ functions, that are
still type checked. Still others with public getters and setters.
Oleh
- Re: Emacs rewrite in a maintainable language, (continued)
- Re: Emacs rewrite in a maintainable language, Richard Stallman, 2015/10/15
- Re: Emacs rewrite in a maintainable language, Rustom Mody, 2015/10/12
- Re: Emacs rewrite in a maintainable language, Michael Heerdegen, 2015/10/12
- Re: Emacs rewrite in a maintainable language, John Wiegley, 2015/10/11
- Re: Emacs rewrite in a maintainable language, David Kastrup, 2015/10/12
- 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 <=
- 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, 2015/10/13
- Re: Emacs rewrite in a maintainable language, Artur Malabarba, 2015/10/13