emacs-devel
[Top][All Lists]
Advanced

[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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]