[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: [External] : Re: Passing result of macroexpand-all as argument to a
From: |
Heime |
Subject: |
RE: [External] : Re: Passing result of macroexpand-all as argument to a function |
Date: |
Wed, 09 Aug 2023 02:53:41 +0000 |
------- Original Message -------
On Wednesday, August 9th, 2023 at 2:27 PM, Drew Adams <drew.adams@oracle.com>
wrote:
> > > > 1- What is the problem that you are trying to solve?
> > >
> > > 2- If you want to pass something to a function and you want that
> > > something
> > > not evaluated, then: quote it. The function can later evaluate it if it
> > > needs to extract the result of the expression, or it can print it using
> > > a
> > > string formatting function.
> > >
> > > 3- If #2 is not clear, reading a LISP tutorial will help. Investing time
> > > reading on LISP and Emacs Lisp will help a lot.
> >
> > I am going to pass
> > (myfunc (macroexpand-all something arg) bfname)
> >
> > How would I define myfunc ?
> >
> > Will (macroexpand-all something arg) be in a form of a list (list of names
> > and arguments) or what ?
>
>
> As several have said, a Lisp macro takes a list sexp that has a symbol car,
> that is, something that looks like a function call: (foo...), and it returns
> a Lisp form - pretty much any kind of Lisp object you like: a string, a
> symbol, a list, a vector, a character or other number.
>
> `macroexpand-all` just expands the macro calls at all levels of its FORM
> argument: the topmost sexp and any sexps inside it - all the way down.
>
> You've already been told that if you want to pass a Lisp object to a function
> without it being evaluated then quote it.
>
> Since you want `macroexpand-all' to first expand your` something' form, you
> want to quote it after evaluating the `macroexpand-all' call. How to do that
> is the among the FAQiest FAQs: https://emacs.stackexchange.com/q/7481 IOW,
> (myfunc` ,(macroexpand-all something arg))
Did not occur to me to quote it. Still I know what quoting means.
I want to pass other variables to my function, example a a buffer name like so
(myfunc ` ,(macroexpand-all something arg) bfname)
So you want to quote it, but then execute macroexpand-all
What I am worried about is this. Would myfunc get confused when the code of
macroexpand-all ends and when bfname starts ?
If I understand correctly, just calling would get the result from
(macroexpand-all something arg) but then evaluate it because the macro
code changes in context when used as an argument to a function.
(myfunc (macroexpand-all something arg) bfname)
> As many have suggested to you ... the Elisp Intro manual is your friend, as
> is
> the Elisp manual. It has a wealth of clear explanation and unlimited patience.
I just say things how they are. If I do not understand and the manual is of no
help
(to me of course), no amount of abuse from anyone will convince my
understanding.
If you want to help someone, one should not expect a certain result. Because
the
result is not up to you. The result is determined by the person who receives
it.
- Passing result of macroexpand-all as argument to a function, Heime, 2023/08/08
- Re: Passing result of macroexpand-all as argument to a function, Pierre Rouleau, 2023/08/08
- Re: [External] : Re: Passing result of macroexpand-all as argument to a function, Michael Heerdegen, 2023/08/08
- Re: [External] : Re: Passing result of macroexpand-all as argument to a function, Heime, 2023/08/09
- Re: [External] : Re: Passing result of macroexpand-all as argument to a function, Michael Heerdegen, 2023/08/09
- Re: [External] : Re: Passing result of macroexpand-all as argument to a function, Heime, 2023/08/09
- RE: [External] : Re: Passing result of macroexpand-all as argument to a function, Drew Adams, 2023/08/09
- RE: [External] : Re: Passing result of macroexpand-all as argument to a function, Drew Adams, 2023/08/09
- Re: Passing result of macroexpand-all as argument to a function, Michael Heerdegen, 2023/08/08
- Re: Passing result of macroexpand-all as argument to a function, Heime, 2023/08/09