all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Tino Calancha <tino.calancha@gmail.com>
To: emacs-devel@gnu.org
Subject: humble proposal: New special form progn-1
Date: Wed, 27 Jul 2016 21:16:28 +0900 (JST)	[thread overview]
Message-ID: <alpine.DEB.2.20.1607272106340.17662@calancha-pc> (raw)


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 <tino.calancha@gmail.com>
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




             reply	other threads:[~2016-07-27 12:16 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-27 12:16 Tino Calancha [this message]
2016-07-27 12:22 ` humble proposal: New special form progn-1 Stefan Monnier
2016-07-27 12:53 ` Andreas Schwab
2016-07-27 13:58   ` Tino Calancha
2016-07-27 16:04     ` Andreas Schwab
2016-07-27 14:08 ` Clément Pit--Claudel
2016-07-27 14:30   ` Phil Sainty
2016-07-27 15:15     ` Drew Adams
2016-07-28 11:35       ` Tino Calancha
2016-07-27 14:38   ` Tino Calancha
2016-07-27 19:07     ` Clément Pit--Claudel
2016-07-27 21:51       ` Nicolas Petton

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.DEB.2.20.1607272106340.17662@calancha-pc \
    --to=tino.calancha@gmail.com \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.