From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: David Kastrup Newsgroups: gmane.emacs.devel Subject: Re: Emacs rewrite in a maintainable language Date: Mon, 12 Oct 2015 17:35:21 +0200 Message-ID: <87vbac9k1y.fsf@fencepost.gnu.org> References: <561A19AB.5060001@cumego.com> <87io6dl0h0.fsf@wanadoo.es> <87lhb82qxc.fsf@gmail.com> <878u78b3hg.fsf@fencepost.gnu.org> <87h9lwyv33.fsf@gmail.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1444664168 9489 80.91.229.3 (12 Oct 2015 15:36:08 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 12 Oct 2015 15:36:08 +0000 (UTC) Cc: =?iso-8859-1?Q?=D3scar?= Fuentes , emacs-devel@gnu.org To: Oleh Krehel Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Oct 12 17:36:07 2015 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Zlf8r-0003TN-Qc for ged-emacs-devel@m.gmane.org; Mon, 12 Oct 2015 17:36:01 +0200 Original-Received: from localhost ([::1]:56179 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zlf8q-00082o-WF for ged-emacs-devel@m.gmane.org; Mon, 12 Oct 2015 11:36:01 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:60483) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zlf8K-00082N-03 for emacs-devel@gnu.org; Mon, 12 Oct 2015 11:35:28 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zlf8J-0003Hv-1E for emacs-devel@gnu.org; Mon, 12 Oct 2015 11:35:27 -0400 Original-Received: from fencepost.gnu.org ([2001:4830:134:3::e]:41557) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zlf8E-0003FH-Jo; Mon, 12 Oct 2015 11:35:22 -0400 Original-Received: from localhost ([127.0.0.1]:55376 helo=lola) by fencepost.gnu.org with esmtp (Exim 4.82) (envelope-from ) id 1Zlf8D-0002ux-UT; Mon, 12 Oct 2015 11:35:22 -0400 Original-Received: by lola (Postfix, from userid 1000) id 501DEE0F01; Mon, 12 Oct 2015 17:35:21 +0200 (CEST) In-Reply-To: <87h9lwyv33.fsf@gmail.com> (Oleh Krehel's message of "Mon, 12 Oct 2015 17:17:52 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:4830:134:3::e X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:191355 Archived-At: Oleh Krehel 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