From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Oleh Krehel Newsgroups: gmane.emacs.devel Subject: Re: Emacs rewrite in a maintainable language Date: Mon, 12 Oct 2015 17:17:52 +0200 Message-ID: <87h9lwyv33.fsf@gmail.com> References: <561A19AB.5060001@cumego.com> <87io6dl0h0.fsf@wanadoo.es> <87lhb82qxc.fsf@gmail.com> <878u78b3hg.fsf@fencepost.gnu.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1444663183 24648 80.91.229.3 (12 Oct 2015 15:19:43 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 12 Oct 2015 15:19:43 +0000 (UTC) Cc: =?utf-8?Q?=C3=93scar?= Fuentes , emacs-devel@gnu.org To: David Kastrup Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Oct 12 17:19:37 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 1Zlesy-0004Cw-V4 for ged-emacs-devel@m.gmane.org; Mon, 12 Oct 2015 17:19:37 +0200 Original-Received: from localhost ([::1]:56074 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zlesy-0004bY-J1 for ged-emacs-devel@m.gmane.org; Mon, 12 Oct 2015 11:19:36 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:53313) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zler8-0002ux-CE for emacs-devel@gnu.org; Mon, 12 Oct 2015 11:17:47 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zler3-00051w-Q0 for emacs-devel@gnu.org; Mon, 12 Oct 2015 11:17:42 -0400 Original-Received: from mail-wi0-x22f.google.com ([2a00:1450:400c:c05::22f]:37833) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zler3-00051a-K7; Mon, 12 Oct 2015 11:17:37 -0400 Original-Received: by wijq8 with SMTP id q8so62821601wij.0; Mon, 12 Oct 2015 08:17:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-type; bh=ayQh812GdXuU23X5WYJtyIKKDbiQnsdVFjPwRond0oU=; b=xg/aavU+fnp1sg1f36znxkH30ro0gfU/4L7DAGpbAdSiwdt678JPwaLVcwNolUOppc TT0ztK9DYNZSaUyOv7OCdIvxEwDH9o/+w5CiWPw9EFhcHyYTjiq3J2bqFd6XhzdHZayy MW1D0cbH5WtCfe73t8ZXGCtjdlJXU3vJARoaGIF83fQUHyJdN+3TBNVew7gLo6nzTKKx u+B44gwevlZb1641tJHm2C4uWUJXqapHBi0WJUXcTfg0ygbMOWlBHyq1iljTzxzl/760 7+dRshgZDGKWgbg1V2hQYCCCpYTIawBwe+p87x92PkYsi0zTNmbn86prjMzim8aqp/Ed 7+ig== X-Received: by 10.180.211.116 with SMTP id nb20mr15882890wic.50.1444663056916; Mon, 12 Oct 2015 08:17:36 -0700 (PDT) Original-Received: from firefly (dyn069045.nbw.tue.nl. [131.155.69.45]) by smtp.gmail.com with ESMTPSA id ld5sm20429924wjc.18.2015.10.12.08.17.35 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Mon, 12 Oct 2015 08:17:35 -0700 (PDT) In-Reply-To: <878u78b3hg.fsf@fencepost.gnu.org> (David Kastrup's message of "Mon, 12 Oct 2015 15:50:19 +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: 2a00:1450:400c:c05::22f 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:191351 Archived-At: David Kastrup writes: > Oleh Krehel 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