[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: macro that uses local variables
From: |
Heime |
Subject: |
Re: macro that uses local variables |
Date: |
Wed, 09 Aug 2023 03:09:48 +0000 |
Sent with Proton Mail secure email.
------- Original Message -------
On Tuesday, August 8th, 2023 at 1:27 PM, Emanuel Berg <incal@dataswamp.org>
wrote:
> Heime wrote:
>
> > I am using the rocket equation in this macro [...]
> >
> > (defmacro booster-velocity-change
> > (specific-impulse standard-gravity initial-mass final-mass)
> > "Compute change of velocity using rocket equation."
> > `(* (* ,specific-impulse ,standard-gravity)
> > (log (mass-ratio ,initial-mass ,final-mass))) )
>
>
> There is no reason to write a macro for this
> simple computation.
>
> > I want to change it such that the arguments are set as local
> > variables
>
>
> Lexical scope, defun, arguments, if need be `let'. It is
> super easy.
>
> If you start thinking "how do I solve my problem?" instead of
> "how do I do <something> in Emacs", everything will be much
> easier for you ...
In the context of a macro, the 'let' command should happen outside tho macro
quote. With the quote expression in the body. Am I right ?
(defmacro booster-velocity-change
(specific-impulse initial-mass final-mass)
"Compute change of velocity using rocket equation."
(let ( (gravity 9.81) )
`(* (* ,specific-impulse ,gravity)
(log (mass-ratio ,initial-mass ,final-mass))) ))
> --
> underground experts united
> https://dataswamp.org/~incal