all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Basil L. Contovounesios" <contovob@tcd.ie>
To: Lars Ingebrigtsen <larsi@gnus.org>
Cc: Eli Zaretskii <eliz@gnu.org>, Leo Liu <sdl.web@gmail.com>,
	emacs-devel@gnu.org
Subject: Re: Has eval-and-compile changed in emacs 27?
Date: Thu, 25 Feb 2021 15:30:17 +0000	[thread overview]
Message-ID: <87k0qwxj06.fsf@tcd.ie> (raw)
In-Reply-To: <8735xk5gqi.fsf@gnus.org> (Lars Ingebrigtsen's message of "Thu, 25 Feb 2021 16:06:45 +0100")

Lars Ingebrigtsen <larsi@gnus.org> writes:

> Eli Zaretskii <eliz@gnu.org> writes:
>
>> eval-and-compile doesn't make sure the function is known at run time,
>> it only makes sure it is known at compile time.
>
> That's `eval-when-compile', surely...  `eval-and-compile' also evaluates
> at load time.

Yes, but non-top-level requires don't usually make functions known at
run time; for that one needs autoload/declare-function.

Here's how I'd write this particular code, for example:

  (autoload 'json-encode "json")

  (defun
    ...
    (if (not json)
        (pp table (current-buffer))
      (defvar json-encoding-pretty-print)
      (let ((json-encoding-pretty-print t))
        (insert (json-encode table))))
    ...)

or alternatively:

  (defun
    ...
    (if (not json)
        (pp table (current-buffer))
      (require 'json)
      (defvar json-encoding-pretty-print)
      (declare-function json-encode "json" (object))
      (let ((json-encoding-pretty-print t))
        (insert (json-encode table))))
    ...

-- 
Basil



  parent reply	other threads:[~2021-02-25 15:30 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-25 13:06 Has eval-and-compile changed in emacs 27? Leo Liu
2021-02-25 14:59 ` Eli Zaretskii
2021-02-25 15:06   ` Lars Ingebrigtsen
2021-02-25 15:23     ` Eli Zaretskii
2021-02-25 21:59       ` Leo Liu
2021-02-25 15:30     ` Basil L. Contovounesios [this message]
2021-02-25 16:18 ` Stefan Monnier
2021-02-25 16:28   ` Stefan Monnier
2021-02-25 21:55     ` Leo Liu
2021-02-25 22:29       ` Stefan Monnier
2021-02-26  2:40         ` Leo Liu
2021-02-26  3:54           ` Stefan Monnier
2021-02-26  8:40             ` Leo Liu
2021-02-26  9:21               ` Basil L. Contovounesios
2021-02-26  9:33                 ` Basil L. Contovounesios
2021-02-26 12:06                   ` Eli Zaretskii
2021-02-28  1:35                 ` Leo Liu
2021-02-28  5:04                   ` Stefan Monnier
2021-02-26 14:06               ` Stefan Monnier
2021-02-26  6:36     ` Richard Stallman
2021-02-26  7:54       ` Eli Zaretskii
2021-02-26  9:09         ` Basil L. Contovounesios
2021-02-27  0:34         ` Tomas Hlavaty
2021-02-27  7:16           ` Eli Zaretskii

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=87k0qwxj06.fsf@tcd.ie \
    --to=contovob@tcd.ie \
    --cc=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=larsi@gnus.org \
    --cc=sdl.web@gmail.com \
    /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.