emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: humble proposal: New special form progn-1


From: Clément Pit--Claudel
Subject: Re: humble proposal: New special form progn-1
Date: Wed, 27 Jul 2016 10:08:32 -0400
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0

On 2016-07-27 08:16, Tino Calancha wrote:
> 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.

:) I don't have anything strongly against it myself. Any reason to not make it 
a lisp macro though?

> 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):

Sounds good. One worry that I have with the name is that I read it as 
(progn)-(1), not prog(n-1).

But in any case, maybe it would be best to make it a lisp macro first?

> ...
> (prog2
>     (progn
>       (form1)
>       (form2)
>       (form3)
>       .
>       .
>       .
>       (formN-2))
>     (prog1
>       (formN-1)
>       (formN)))


Wouldn't 
(progn 
  (form1)
  ...
  (formN-2)
  (prog1
    (formN-1)
    (formN)))
work?

Cheers,
Clément.

> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
>> From c9b38c42b253ca004c3aef4dd9dde274aa717d91 Mon Sep 17 00:00:00 2001
> From: Tino Calancha <address@hidden>
> 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);

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]