From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Tino Calancha Newsgroups: gmane.emacs.devel Subject: humble proposal: New special form progn-1 Date: Wed, 27 Jul 2016 21:16:28 +0900 (JST) Message-ID: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; format=flowed; charset=US-ASCII X-Trace: ger.gmane.org 1469621811 17720 80.91.229.3 (27 Jul 2016 12:16:51 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 27 Jul 2016 12:16:51 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Jul 27 14:16:49 2016 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 1bSNlZ-0008EB-7Q for ged-emacs-devel@m.gmane.org; Wed, 27 Jul 2016 14:16:49 +0200 Original-Received: from localhost ([::1]:46118 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bSNlV-0002kp-3w for ged-emacs-devel@m.gmane.org; Wed, 27 Jul 2016 08:16:45 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:46355) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bSNlN-0002hl-DI for emacs-devel@gnu.org; Wed, 27 Jul 2016 08:16:38 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bSNlI-00035p-By for emacs-devel@gnu.org; Wed, 27 Jul 2016 08:16:36 -0400 Original-Received: from mail-pf0-x244.google.com ([2607:f8b0:400e:c00::244]:34424) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bSNlI-00035l-3Z for emacs-devel@gnu.org; Wed, 27 Jul 2016 08:16:32 -0400 Original-Received: by mail-pf0-x244.google.com with SMTP id g202so1788080pfb.1 for ; Wed, 27 Jul 2016 05:16:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:date:to:subject:message-id:user-agent:mime-version; bh=TiP1CJp5IGe+QvnqcCOVq9MbLAXloEsgCj/dEMv4mng=; b=j3WGZ9jxoGx3JqmIQdpKHYR4k+Fg6oAA5MMTndFIwLH7HAmmj02FO7SlJybk2j3smf Mdg2Uaz6iNgon9gOU4ig5ULeVRhqYgorCSXTugL2RvtstgqFsex9yXvYACvK6Hxz90vm GQ97EwNgNNyB6I3wJGPtZ62SelxNUe2KwMSfI8eZDOCxkjHYnWAl2vca/+ofiiz0cZT3 hLuvr9aiSVo14XFchUIVsHdml7w1bCY9LsIuAFYNbTMtN4TeiajTfNS6CUsSVHh6TpnV 1qTrjjg7taX/jP7/KBksHgyhnOwFyR2ADwItXtwELvoTLYewvWV5FMZgWv5003tfr0jY 1xgw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:date:to:subject:message-id:user-agent :mime-version; bh=TiP1CJp5IGe+QvnqcCOVq9MbLAXloEsgCj/dEMv4mng=; b=E32w2sIwu6V6FNemp1JD1YLTUJwHYxOkmN1DDH9iAK8KPfnT3YE55T9yw5ABdypvvn 8+JOn3am7TfpePspH9e4fd6UHSNixo+VOIuoW2P7696yyrzBEc+Y67MVmcXG41XjB3sc 8J7gjjnW6QqO4RfDhNKuHrEXuVXMJAu7/p20VINXULoSRHzDqetLTA5xca2eaLwH7wp/ rQ1VjeX7tIguNPuUNApXYvLrSt2B/8ub1tAfh6XAV+0ozXfIURB61k9ALYf3se3d4w2I VgCKkpBqWvbYadspODueNjtvMwviwnGfwwZTf7A90jqlJlqC/wpKOwqDYDJbi076+fBf BSCA== X-Gm-Message-State: AEkooutAoEbJpkajNhf7JHEu7vDK15QI1lWKaVV9BzNvElGa5eO7vAwZYhcGQFXeHTQPAw== X-Received: by 10.98.60.217 with SMTP id b86mr49203641pfk.129.1469621791049; Wed, 27 Jul 2016 05:16:31 -0700 (PDT) Original-Received: from calancha-pc ([210.160.37.26]) by smtp.gmail.com with ESMTPSA id d3sm8950077pfk.37.2016.07.27.05.16.29 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 27 Jul 2016 05:16:30 -0700 (PDT) X-Google-Original-From: Tino Calancha X-X-Sender: calancha@calancha-pc User-Agent: Alpine 2.20 (DEB 67 2015-01-07) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2607:f8b0:400e:c00::244 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 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" Xref: news.gmane.org gmane.emacs.devel:206174 Archived-At: Dear all, i got this idea few days ago (see the patch at the end). Even though I envision that no one here will like this proposal, for me it's instructive to learn from your answers why this is not a good idea. So, why is this a bad idea? Thanks in advance for your answer, Tino My (weak) motivation for introduce this is: * Compact (and familiar) syntaxis. * Same reasons to exists as prog2 has (excluding historical reasons). * Other way to acomplish one usual task. * Allow lower indentation level (see below): (progn-1 (form1) (form2) (form3) . . . (formN-1) (formN)) (prog1 (progn (form1) (form2) (form3) . . . (formN-1)) (formN)) (prog2 (progn (form1) (form2) (form3) . . . (formN-2)) (prog1 (formN-1) (formN))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; >From c9b38c42b253ca004c3aef4dd9dde274aa717d91 Mon Sep 17 00:00:00 2001 From: Tino Calancha Date: Wed, 27 Jul 2016 20:40:25 +0900 Subject: [PATCH] New special form progn-1 * src/eval.c (progn-1): Eval sequentially N forms and return the value of the form N-1. --- src/eval.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/eval.c b/src/eval.c index 33b82f7..5eb0cfd 100644 --- a/src/eval.c +++ b/src/eval.c @@ -431,6 +431,23 @@ usage: (progn BODY...) */) return val; } +DEFUN ("progn-1", Fprogn_1, Sprogn_1, 2, UNEVALLED, 0, + doc: /* Eval N forms sequentially; return value from form N-1. +usage: (progn-1 FORM_1 FORM_2...FORM_N-1 FORM_N) */) + (Lisp_Object body) +{ + Lisp_Object val = Qnil; + + while (CONSP (XCDR (body))) + { + val = eval_sub (XCAR (body)); + body = XCDR (body); + } + eval_sub (XCAR (body)); + + return val; +} + /* Evaluate BODY sequentially, discarding its value. Suitable for record_unwind_protect. */ @@ -3906,6 +3923,7 @@ alist of active lexical bindings. */); defsubr (&Sif); defsubr (&Scond); defsubr (&Sprogn); + defsubr (&Sprogn_1); defsubr (&Sprog1); defsubr (&Sprog2); defsubr (&Ssetq); -- 2.8.1 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; In GNU Emacs 25.1.50.1 (x86_64-pc-linux-gnu, GTK+ Version 3.20.6) of 2016-07-27 built Repository revision: e0d425976e3a83585db9a586687897fe1ac6455f