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: Tue, 13 Oct 2015 13:27:49 +0200 Message-ID: <87oag3xb2i.fsf@gmail.com> References: <561A19AB.5060001@cumego.com> <87io6dl0h0.fsf@wanadoo.es> <87lhb82qxc.fsf@gmail.com> <878u78b3hg.fsf@fencepost.gnu.org> <87h9lwyv33.fsf@gmail.com> <561C368F.6010306@cs.ucla.edu> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1444735729 31733 80.91.229.3 (13 Oct 2015 11:28:49 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 13 Oct 2015 11:28:49 +0000 (UTC) Cc: emacs-devel@gnu.org To: Paul Eggert Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Oct 13 13:28:44 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 1Zlxkz-0003Ou-Tu for ged-emacs-devel@m.gmane.org; Tue, 13 Oct 2015 13:28:38 +0200 Original-Received: from localhost ([::1]:33873 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zlxky-0007mX-V7 for ged-emacs-devel@m.gmane.org; Tue, 13 Oct 2015 07:28:36 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:37666) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zlxk3-0007l7-Uh for emacs-devel@gnu.org; Tue, 13 Oct 2015 07:27:40 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zlxk0-0006Je-MV for emacs-devel@gnu.org; Tue, 13 Oct 2015 07:27:39 -0400 Original-Received: from mail-wi0-x22b.google.com ([2a00:1450:400c:c05::22b]:35348) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zlxk0-0006Ja-Gm for emacs-devel@gnu.org; Tue, 13 Oct 2015 07:27:36 -0400 Original-Received: by wicge5 with SMTP id ge5so186536800wic.0 for ; Tue, 13 Oct 2015 04:27:35 -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=rXmPMDfifuHN8yQWE+vciqMCBCAHp3sLStWmI6qDqEs=; b=dgxA+u/WYqEdEPCNAI/Blaf37M2cH+peef5qQNno0GYhQCbetRrwDqhDzFTBdBc1Ag pClcehm2Weo2wN/H5oGmmLS8RhKzMct0ziH5XQil8m+7UKyZqgHrSoHW3i+qsGtEIaVP d6hZzsioeqtPXhfumPZ16cnEdRQ6RRifXGzGSNO6ZMiiyWV0tuDKe95kf51619XAwes1 rBiqAF8YTnBQ1jVAWFZeRhI/fHpAab7r+22GbTWlHB58H0QZOy9LOVVWZLayvKMSVKnW u5SyQ0X4/RVn1ufrmde0PBI7ffxkTOz8ffvV8gI15UyfnS0S9lEM5yFdrK+Tlb4XQKFv YU2g== X-Received: by 10.195.11.72 with SMTP id eg8mr41053972wjd.14.1444735655628; Tue, 13 Oct 2015 04:27:35 -0700 (PDT) Original-Received: from firefly (dyn069045.nbw.tue.nl. [131.155.69.45]) by smtp.gmail.com with ESMTPSA id d8sm23530206wiy.1.2015.10.13.04.27.34 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Tue, 13 Oct 2015 04:27:34 -0700 (PDT) In-Reply-To: <561C368F.6010306@cs.ucla.edu> (Paul Eggert's message of "Mon, 12 Oct 2015 15:39:11 -0700") 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::22b 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:191445 Archived-At: Paul Eggert writes: > On 10/12/2015 08:17 AM, Oleh Krehel wrote: >> 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++ > > Only BVAR belongs to the Emacs core. The other macros belong to > auxiliary executables that presumably would be unaffected by any > rewrite of the core. Anyway, for fun I just now replaced streq, > SET_FLAG, and HAS_FLAG with functions, in the attached patch. More > work needs to be done in this area but one step at a time.... Thanks, Paul. May I ask if there's a reason to not have a single style for const pointers? I get 2162 occurrences of "const char *", and 357 occurrences of "char const *" in the C sources. I have to admit that I haven't seen the "char const *" variation anywhere before. Just to get another sample, I looked at the Linux sources; their ratio is 31961:189 in favor of "const char *". If no one deems it counter-productive, I'd like to switch all const pointers to a single "const char *" style. If we want more people to be comfortable with the C sources, style and consistency is important. Oleh