unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Michael Heerdegen <michael_heerdegen@web.de>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: emacs-devel@gnu.org
Subject: Re: Why is FUNC in cl-callf not allowed to be an expression?
Date: Thu, 23 May 2019 03:50:38 +0200	[thread overview]
Message-ID: <874l5m2b2p.fsf@web.de> (raw)
In-Reply-To: <87ftp7palg.fsf@web.de> (Michael Heerdegen's message of "Wed, 22 May 2019 03:00:11 +0200")

[-- Attachment #1: Type: text/plain, Size: 711 bytes --]

Michael Heerdegen <michael_heerdegen@web.de> writes:

> With our current implementation of local macros, only the expansion
> (compile) time matters, so this not so simple to do:
>
> (let ((l '(0 1 2 3))
>       (i '(0 1 2 3))
>       (flag nil))
>   (cl-macrolet ((yyy () (if flag '(nth 2 l) '(nth 3 i))))
>     (cl-symbol-macrolet ((xxx (yyy)))
>       (setf xxx 0)
>       (list l i))))
> |- void-variable: flag

Most Common Lisps seem to barf in this case (macro definition
referencing local variables).  I only found it explicitly described
here:

  http://www.lispworks.com/documentation/HyperSpec/Body/s_flet_.htm#macrolet

Anyway, I would like to speak out that one should not do that, how about
this?


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-doc-misc-cl.texi-Macro-Bindings-State-expansion-time.patch --]
[-- Type: text/x-diff, Size: 768 bytes --]

From ae8e42cf23e4883aed0177aad30d56f0e3e5086b Mon Sep 17 00:00:00 2001
From: Michael Heerdegen <michael_heerdegen@web.de>
Date: Thu, 23 May 2019 03:33:04 +0200
Subject: [PATCH] * doc/misc/cl.texi (Macro Bindings): State expansion time

---
 doc/misc/cl.texi | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/doc/misc/cl.texi b/doc/misc/cl.texi
index eb06791ba9..c96b9b6c3e 100644
--- a/doc/misc/cl.texi
+++ b/doc/misc/cl.texi
@@ -1360,6 +1360,8 @@ Macro Bindings
 affect only calls that appear physically within the body
 @var{forms}, possibly after expansion of other macros in the
 body.
+
+Like global macros local macros are expanded at compile-time.
 @end defmac

 @defmac cl-symbol-macrolet (bindings@dots{}) forms@dots{}
--
2.20.1


[-- Attachment #3: Type: text/plain, Size: 11 bytes --]



Michael.

  reply	other threads:[~2019-05-23  1:50 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-09 21:52 Why is FUNC in cl-callf not allowed to be an expression? Michael Heerdegen
2019-05-10  0:47 ` Stefan Monnier
2019-05-10 11:32   ` Michael Heerdegen
2019-05-10 13:28     ` Stefan Monnier
2019-05-10 14:19       ` Stefan Monnier
2019-05-10 14:22         ` Stefan Monnier
2019-05-10 15:18           ` Michael Heerdegen
2019-05-13 16:47             ` Stefan Monnier
2019-05-14 12:36               ` Michael Heerdegen
2019-05-14 23:32               ` Michael Heerdegen
2019-05-15  2:02                 ` Stefan Monnier
2019-05-15 16:38                   ` Michael Heerdegen
2019-05-15 17:19                     ` Michael Heerdegen
2019-05-16  2:18                       ` Michael Heerdegen
2019-05-16 13:12                     ` Stefan Monnier
2019-05-16 14:37                       ` Michael Heerdegen
2019-05-16 15:09                         ` Michael Heerdegen
2019-05-16 19:34                           ` Stefan Monnier
2019-05-16 21:46                             ` Michael Heerdegen
2019-05-16 23:06                               ` Stefan Monnier
2019-05-17 22:53                                 ` Michael Heerdegen
2019-05-18 14:09                                   ` Stefan Monnier
2019-05-20 23:25                                     ` Michael Heerdegen
2019-05-21  2:01                                       ` Stefan Monnier
2019-05-21  2:47                                         ` Michael Heerdegen
2019-05-21 10:16                                           ` Noam Postavsky
2019-05-21 16:38                                             ` Michael Heerdegen
2019-05-21 17:38                                           ` Stefan Monnier
2019-05-21  7:26                                         ` Andy Moreton
2019-05-23 23:02                                           ` Michael Heerdegen
2019-05-22  1:00                                     ` Michael Heerdegen
2019-05-23  1:50                                       ` Michael Heerdegen [this message]
2019-05-23  3:38                                         ` Stefan Monnier
2019-05-23 23:38                                           ` Michael Heerdegen
2019-05-24 15:29                                             ` Stefan Monnier
2019-05-28 19:54                                               ` Michael Heerdegen
2019-05-27  0:20                                     ` Michael Heerdegen
2019-05-29 17:02                                       ` Stefan Monnier
2019-05-15 19:17                   ` Michael Heerdegen

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=874l5m2b2p.fsf@web.de \
    --to=michael_heerdegen@web.de \
    --cc=emacs-devel@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /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 public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).