Subject: bug#70368: [PATCH] Use a dedicated type to represent interpreted-function values

From: Eli Zaretskii <[email-masked]>
Date: Thu, 18 Apr 2024 19:49:36 +0300

> From: Stefan Monnier <[email-masked]>
> Cc: [email-masked]
> Date: Thu, 18 Apr 2024 12:36:36 -0400
> 
> OK, I've updated my patch according to your suggestions, see the result
> below (and in the `scratch/interpreted-function` branch).
> Any further comment/objection?

Just a few minor nits, really.

> >From 7842af6095db4384898725fb4a14ebaa11379a34 Mon Sep 17 00:00:00 2001
> From: Stefan Monnier <[email-masked]>
> Date: Sun, 24 Mar 2024 18:32:25 -0400
> Subject: [PATCH 1/2] (COMPILED): Rename to CLOSURE
> 
> In preparation for the use of `PVEC_COMPILED` objects for
> interpreted functions, rename them to use a more neutral name.
> 
> * src/lisp.h (enum pvec_type): Rename `PVEC_COMPILED` to `PVEC_CLOSURE`.
> (enum Lisp_Compiled): Use `CLOSURE_` prefix i.s.o `COMPILED_`.
> Also use `CODE` rather than `BYTECODE`.
> (CLOSUREP): Rename from `COMPILEDP`.
> (enum Lisp_Closure): Rename from `Lisp_Compiled`.
> 
> * src/alloc.c, src/bytecode.c, src/comp.c, src/data.c, src/eval.c,
> * src/fns.c, src/lisp.h, src/lread.c, src/pdumper.c, src/print.c,
> * src/profiler.c: Rename all uses accordingly.
> * src/.gdbinit (xclosure): Rename from `xcompiled`.
> (xcompiled): New obsolete alias.
> (xpr): Adjust accordingly.  Also adjust to new PVEC_CLOSURE tag name.

You are still quoting `like this`.

> +Thus code that attempts to "dig" into the internal structure of an
> +interpreted function's object with the likes of 'car' or 'cdr' will
> +no longer work and will need to use 'aref' used instead to extract its
                                              ^^^^
That "used" should be removed.

> +DEFUN ("closurep", Fclosurep, Sclosurep,
> +       1, 1, 0,
> +       doc: /* Return t if OBJECT is a function of type `closure'.  */)
> +  (Lisp_Object object)
> +{
> +  if (CLOSUREP (object))
> +    return Qt;
> +  return Qnil;
> +}

This new function should be in NEWS.

> +DEFUN ("interpreted-function-p", Finterpreted_function_p,
> +       Sinterpreted_function_p, 1, 1, 0,
> +       doc: /* Return t if OBJECT is a function of type `interpreted-function'.  */)
> +  (Lisp_Object object)

Likewise.

> +DEFUN ("make-interpreted-closure", Fmake_interpreted_closure,
> +       Smake_interpreted_closure, 3, 5, 0,
> +       doc: /* Make an interpreted closure.
> +ARGS should be the list of formal arguments.
> +BODY should be a non-empty list of forms.
> +ENV should be a lexical environment, like the second argument of `eval'.
> +IFORM if non-nil should be of the form (interactive ...).  */)
> +  (Lisp_Object args, Lisp_Object body, Lisp_Object env,
> +   Lisp_Object docstring, Lisp_Object iform)

Likewise.

Thanks.