[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#64584: 29.0.91; skeleton: cannot pass `str' as argument to some func
From: |
Stefan Monnier |
Subject: |
bug#64584: 29.0.91; skeleton: cannot pass `str' as argument to some functions |
Date: |
Tue, 12 Sep 2023 09:08:09 -0400 |
User-agent: |
Gnus/5.13 (Gnus v5.13) |
> Yes, but here it basically does nothing unfortunately. I am not sure if
>
> 'str
>
> should have the side effect of setting that variable.
The above skeleton expression means "eval the variable `str` and throw
away the result". The only effect it can have is to signal an error if
the variable `str` is not bound.
> (defmacro vz/snippet-when (form &rest body)
> "Evaluate BODY if FORM returns non-nil or non-empty string."
> (declare (indent 1) (debug (form body)))
> `(let ((str ,form))
> (if (and str (equal str ""))
> ""
> ,@body)))
FWIW, this style of macro is usually called "anaphoric macro" and the
convention is to use the identifier `it` rather than `str` in them.
It would help avoid a confusion between skeleton's `str` and your
macro's variable.
[ And, yes, arguably, `define-skeleton` could be considered as an
anaphoric macro as well which should use `it` instead of `str`,
bringing back the confusion :-) ]
Stefan