help-gnu-emacs
[Top][All Lists]
Advanced

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

RE: [External] : Re: How to make M-x TAB not work on (interactive) decla


From: Drew Adams
Subject: RE: [External] : Re: How to make M-x TAB not work on (interactive) declaration?
Date: Sun, 8 Jan 2023 22:35:19 +0000

> Then is not good to say "it should be a list of
> mode names". Of course after &rest the argument
> becomes list, but is not same thing.

I' sure you know this, but maybe it's worth
repeating:

Yes and no.  Yes, a parameter specified in a
function definition is not the same thing as an
actual argument in a given application of the
function.

But no, depending on how "it" is read, it _can_
be said to be the same thing.

MODES is a formal parameter in the function
definition, but MODES is also the name of a
local variable in the function, a variable
that's bound, when the function is called, to
a list of actual arguments.  In a function call,
MODES _is_ the list of argument values; that is,
the value of variable MODES is that list.

(defun foo (a &rest b) (message "A: %S, B: %S" a b))
(foo 1 2 3 4)
==> "A: 1, B: (2 3 4)"

This is the definition of an &rest parameter.
`&rest MODES' is a formal parameter spec
(part of a "lambda list", which is part of a
function definition), which corresponds to a
list (possibly empty) of actual arguments.
Same thing in a lambda expression (definition
of an anonymous function).

https://www.cs.cmu.edu/Groups/AI/html/cltl/clm/node64.html

"the lambda-list ... specifies names for the
 parameters of the function. When the function
 denoted by the lambda-expression is applied to
 arguments, the arguments are matched with the
 parameters specified by the lambda-list."

What is this "matching" for &rest?

"remaining arguments are made into a list for
 the &rest parameter"

reply via email to

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