From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Tom Tromey Newsgroups: gmane.emacs.devel Subject: Re: Emacs rewrite in a maintainable language Date: Sun, 18 Oct 2015 10:58:58 -0600 Message-ID: <87k2qknmel.fsf@tromey.com> References: <561A19AB.5060001@cumego.com> <87io6dl0h0.fsf@wanadoo.es> <87lhb82qxc.fsf@gmail.com> <87oag4jk74.fsf@wanadoo.es> <87k2qrki45.fsf@wanadoo.es> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1445187603 672 80.91.229.3 (18 Oct 2015 17:00:03 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 18 Oct 2015 17:00:03 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Oct 18 18:59:47 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 1ZnrJB-0008O9-Fc for ged-emacs-devel@m.gmane.org; Sun, 18 Oct 2015 18:59:45 +0200 Original-Received: from localhost ([::1]:34658 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZnrJA-0006bP-LZ for ged-emacs-devel@m.gmane.org; Sun, 18 Oct 2015 12:59:44 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:42229) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZnrIt-0006as-UP for emacs-devel@gnu.org; Sun, 18 Oct 2015 12:59:31 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZnrIh-0008T9-Vc for emacs-devel@gnu.org; Sun, 18 Oct 2015 12:59:19 -0400 Original-Received: from gproxy2-pub.mail.unifiedlayer.com ([69.89.18.3]:50003) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1ZnrIh-0008Sk-KK for emacs-devel@gnu.org; Sun, 18 Oct 2015 12:59:15 -0400 Original-Received: (qmail 12223 invoked by uid 0); 18 Oct 2015 16:59:08 -0000 Original-Received: from unknown (HELO cmgw4) (10.0.90.85) by gproxy2.mail.unifiedlayer.com with SMTP; 18 Oct 2015 16:59:08 -0000 Original-Received: from box522.bluehost.com ([74.220.219.122]) by cmgw4 with id Wgz41r00E2f2jeq01gz7JE; Sun, 18 Oct 2015 10:59:08 -0600 X-Authority-Analysis: v=2.1 cv=IekUBwaa c=1 sm=1 tr=0 a=GsOEXm/OWkKvwdLVJsfwcA==:117 a=GsOEXm/OWkKvwdLVJsfwcA==:17 a=cNaOj0WVAAAA:8 a=f5113yIGAAAA:8 a=zstS-IiYAAAA:8 a=PnD2wP_eR3oA:10 a=L_bIm3w8_ccA:10 a=5lJygRwiOn0A:10 a=NEAV23lmAAAA:8 a=0MZco5MQ42MrJt4pH1QA:9 a=JcMbS4h00uzF1_Rp:21 a=YQI1bnxKC8A39XKP:21 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Content-Type:MIME-Version:Message-ID:In-Reply-To:Date:References:Subject:To:From; bh=HnYxBJeHeqKIvUmhRJIGhGox824t8lsslUqcMKaHn/w=; b=jJOztlgc3XX8s3zzM2z4xl2NyYEILDAZZ87EWsz4YUl2My9+oDXWHmLjQRitrTuqhNUbP7sPwhn1tHyEjuOPGPiDTJ36ojsBlVWpzgxDmIzFKcLaaYZNr8VfK3s6HeR9; Original-Received: from [71.208.226.194] (port=23849 helo=bapiya) by box522.bluehost.com with esmtpsa (TLSv1.2:AES128-GCM-SHA256:128) (Exim 4.84) (envelope-from ) id 1ZnrIV-0002sw-VS; Sun, 18 Oct 2015 10:59:04 -0600 X-Attribution: Tom In-Reply-To: (John Wiegley's message of "Mon, 12 Oct 2015 12:39:32 -0700") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux) X-Identified-User: {36111:box522.bluehost.com:elynrobi:tromey.com} {sentby:smtp auth 71.208.226.194 authed with tom+tromey.com} X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 69.89.18.3 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:191974 Archived-At: John> If they are amenable, would you be willing to prototype it? If we John> could see a language description for the subset/alternate, and a John> sample compilation into C for some of the functions we have in John> Emacs core (that is, reimplementing them as a proof of concept), John> that would help sell it. You don't really need to do any subsetting. With a decent compiler you can just write elisp. This is pretty much what I am trying to do here: https://github.com/tromey/el-compilador My test case is a chunk of fns.c rewritten into ordinary Emacs Lisp. See appended. The C output is gross, but of course it doesn't matter. (And the C output is incorrect, which does matter. But it's a WIP.) I chose chunks of fns.c to translate because these are close to "pure lisp" - no difficult native code to handle. One of the next steps is wiring it up to FFI so that native calls can be implemented in the compiler. See https://github.com/tromey/emacs-ffi This is even rougher; but the basic idea is to reuse FFI function declarations in the C back end of the compiler to emit direct native calls. Tom Input: (defun nthcdr (num list) (cl-check-type num integer) (let ((i 0)) (while (and (< i num) list) (setq list (cdr list)) (setq i (1+ i))) list)) Output: #include #include int plugin_is_GPL_compatible; static Lisp_Object Qinteger; static Lisp_Object Qnum; static Lisp_Object Qwrong_type_argument; static Lisp_Object Knthcdr; DEFUN ("nthcdr", Fnthcdr, Snthcdr, 2, 2, 0, doc: /* nothing?? */) (Lisp_Object num, Lisp_Object list) { Lisp_Object G1_5; Lisp_Object i_13; Lisp_Object G4_18; Lisp_Object i_17; Lisp_Object num_14; Lisp_Object list_15; Lisp_Object list_36; Lisp_Object i_37; Lisp_Object G3_12; BB_0: G1_5 = Fintegerp (num); if (!NILP (G1_5)) goto BB_1; else goto BB_2; BB_1: i_13 = make_number (0); goto BB_5; BB_5: G4_18 = F< (i_17, num_14); if (!NILP (G4_18)) goto BB_8; else goto BB_6; BB_8: if (!NILP (list_15)) goto BB_10; else goto BB_6; BB_10: list_36 = Fcdr (list_15); i_37 = F1+ (i_17); goto BB_5; BB_6: return list_15; BB_2: G3_12 = Flist (Qinteger, num, Qnum); Ffuncall (3, ((Lisp_Object[]) { signal, Qwrong_type_argument, G3_12 })); } void init (void) { Qinteger = intern_c_string ("integer"); staticpro (&Qinteger); Qnum = intern_c_string ("num"); staticpro (&Qnum); Qwrong_type_argument = intern_c_string ("wrong-type-argument"); staticpro (&Qwrong_type_argument); defsubr (&Snthcdr); XSETSUBR (Knthcdr, &Snthcdr); }