all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Tim Johnson <tim@akwebsoft.com>
To: help-gnu-emacs@gnu.org
Subject: Re: Proper use of function form
Date: Sun, 26 Apr 2020 16:43:46 -0800	[thread overview]
Message-ID: <b74c7855-b618-0019-3cba-7930ac805baf@akwebsoft.com> (raw)
In-Reply-To: <87h7x5kd2u.fsf@web.de>


On 4/26/20 4:05 PM, Michael Heerdegen wrote:
> Tim Johnson <tim@akwebsoft.com> writes:
>
>> Would it be better to change (nth (+ ndx 1) mylist) to
>> (function (nth > (+ ndx 1) mylist)) ?
> No:
>
> "Like `quote', but preferred for objects which are functions.
> In byte compilation, `function' causes its argument to be handled by
> the byte compiler.  `quote' cannot do that."
>
> "(nth > (+ ndx 1) mylist)" is not a function - it is an
> expression that will evaluate to a function.  Since `function' acts like
> `quote', using this special form would prevent that evaluation, so it
> won't work.
>
> The underlying problem is that your expression is evaluated at
> run-time.  Useful for the compiler would only be a function name known
> at compile time.  If you know the function name at compile time, you
> don't want to eval it at run time, so you want to `quote' anyway.
>
> So what can you do?  Since we don't have a multiple-define-key function,
> you can just stay with your loop as is - there is nothing wrong with
> that, but you'll not get compiler warnings like "unknown function".  You
> can also use a macro that would expand to a sequence of `define-key'
> calls at compile time.  Or construct the whole keymap at compile time,
> using list functions (or `backquote').  But that's rather uncommon.
> Most people just write the key definition calls out or just don't care -
> even in the Emacs sources.

Thanks Michael. I will leave will enough alone.

cheers

-- 
Tim
tj49.com




  reply	other threads:[~2020-04-27  0:43 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-26 23:27 Proper use of function form Tim Johnson
2020-04-27  0:05 ` Michael Heerdegen
2020-04-27  0:43   ` Tim Johnson [this message]
2020-04-27  0:48 ` Noam Postavsky
2020-04-27  1:58   ` Tim Johnson
2020-04-27  8:06 ` Emanuel Berg via Users list for the GNU Emacs text editor
2020-04-27 19:12   ` Tim Johnson

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=b74c7855-b618-0019-3cba-7930ac805baf@akwebsoft.com \
    --to=tim@akwebsoft.com \
    --cc=help-gnu-emacs@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.