[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Emacs rewrite in a maintainable language
From: |
David Kastrup |
Subject: |
Re: Emacs rewrite in a maintainable language |
Date: |
Mon, 12 Oct 2015 17:35:21 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux) |
Oleh Krehel <address@hidden> writes:
>
>> "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.
"type checked" in the meaning that they will just grab suitable
operators for the given types and create code from them, just like
macros do just with much more complex semantics. And you finally get to
write the stuff just like you did before. The code using the stuff will
be just as readable, but figuring out what happens becomes harder.
> Still others with public getters and setters.
Shrug. That looks a lot like C++ for C++' sake. As I said: we do use
C++ in LilyPond, a high-level application built atop of the Scheme
interpreter GUILE (written in C itself). And we get sort of a
reasonable payoff. But the Elisp implementation is not a complex
high-level application. It's a low-level wrapping akin to how GUILE
wraps Scheme in C. And cobbling higher-level stuff together should
rather happen at the Elisp level than in a semi-parallel C/C++ level.
--
David Kastrup
- 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, 2015/10/12
- Re: Emacs rewrite in a maintainable language,
David Kastrup <=
- 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
- Re: Emacs rewrite in a maintainable language, David Kastrup, 2015/10/13